new 主类(ip,port), 其构造函数中直接连接
public String routeTest() throws IOException, Exception {
int headchar;
InputStreamReader isr = new InputStreamReader(in,getRoute_Read_mode());
while ((headchar = isr.read()) != -1 ) {
System.out.print((char) headchar);
if( !Character.isLetterOrDigit( (char)headchar ) //非数字 非字母 不包含一下字符
&& (char)headchar !=' '
&& (char)headchar !=':'
&& (char)headchar !='.'
&& (char)headchar !='\r'
&& (char)headchar !='\n'
&& (char)headchar !=';'
&& (char)headchar !='='
&& (char)headchar !='('
&& (char)headchar !=')') {
head += (char) headchar;//报头
}
else{
head_info += (char) headchar;//默认方式登录 能看到的信息
}
if(isr.ready() == false){ //读完 break
System.out.print("\n读取 阻塞 break!!");
break;
}
}
System.out.println("报头:\t"+head);
System.out.println("信息:\t"+head_info.trim());
this.disconnect_Route();//断开 连接
return head_info;
}
报头: ????????????(存为char )
信息: Welcome Visiting Huawei Home Gateway
Copyright by Huawei Technologies Co. Ltd.
Login:
报头: ??????!????
信息: F660
Login:
报头: ??????!????
信息:(none) login: