由于调用socket.close()似乎并未中断br.readLine()处的块,因此我做了一些解决方法。当断开客户端与服务器的连接时,我仅发送字符串“
bye”,并告诉服务器在收到此命令时关闭套接字连接。
while ((str = br.readLine()) != null){ // If we receive a command of "bye" the RemoteControl is instructing // the RemoteReceiver to close the connection. if (str.equalsIgnoreCase("bye")){ socket.close(); break; } System.out.println("Processing command " + str); pw.println(client.message(str));}


