更新时间:2022-04-20 23:09:52
几点:
1)输入结束循环的条件不正确:
1) incorrect conditions for end of input loop:
while (inputMessage.equals("QUIT")); // Server#processConnection
while (outputMessage.equals("QUIT")) // Client#processConnection
这些应该被否定(!)。
these should be negated ("!").
2)你应该开始 System.in
阅读主题:
2) you should start you System.in
reading threads:
new Thread() { // instead of `Runnable`
...
}.start();
3)你应该在服务器上断开监听循环,例如 EOFException
,表示客户端已断开连接。
3) you should break listening loop on server for some exceptions, like EOFException
which means that client was disconnected.