对于我来说没有什么问题得到while循环后执行?什么是与这个问题? (while循环永远不会被执行结束后的行)
客户端的ServerSocket.accept =();在的BufferedReader =新的BufferedReader( 新的InputStreamReader(client.getInputStream()));而((行= in.readLine())!= NULL){ Log.i(线,线); line111 + =行; Log.i(line111,line111);}//不执行低于此的任何codeLog.i(山,山);
解决方案
您while循环卡住等待插座下一行上。流的来源需要关闭其端的连接。
The problem for me nothing gets executed after while loop? what's the issue with that? (The lines after the end of while loop never gets executed)
client = serverSocket.accept();
BufferedReader in = new BufferedReader(
new InputStreamReader(client.getInputStream())
);
while ((line = in.readLine()) != null) {
Log.i("line",line);
line111 +=line;
Log.i("line111",line111);
}
//Any code below this is not executed
Log.i("shan","Shan");
解决方案
Your while loop is stuck waiting on the socket for the next line. The source of the stream needs to close the connection at its end.