我是一个Java初学者,不熟悉Java套接字编程。我需要处理客户端断开连接的事件。我在Java中搜索了如何使用read*,write*函数来检测套接字断开,有人说:
read() will return -1
readLine() returns null
readXXX() for any other X throws EOFException.
The only really reliable way to detect a lost TCP connection is to write to it. Eventually this will throw an IOException: