java客户端的接收函数的代码:try{
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
System.out.println(in.readLine());
} catch(IOException ex){
ex.printStackTrace();
}
用in.readLine只能接收单片机服务端返回过来的一行数据,服务端是用C写的,返回数据有多行,如果把代码加上循环:try{
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
String ss=null;
while((ss=in.readLine())!=null){
System.out.println(ss);
}
//System.out.println(in.readLine());
} catch(IOException ex){
ex.printStackTrace();
}
结果只能连接一次,再连接服务端就连接不上了,提示:连接拒绝
问:这种情况是什么原因造成的,怎么解决?
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
System.out.println(in.readLine());
} catch(IOException ex){
ex.printStackTrace();
}
用in.readLine只能接收单片机服务端返回过来的一行数据,服务端是用C写的,返回数据有多行,如果把代码加上循环:try{
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
String ss=null;
while((ss=in.readLine())!=null){
System.out.println(ss);
}
//System.out.println(in.readLine());
} catch(IOException ex){
ex.printStackTrace();
}
结果只能连接一次,再连接服务端就连接不上了,提示:连接拒绝
问:这种情况是什么原因造成的,怎么解决?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货