An EOFException is thrown when the socket connection is no longer valid. This usually happens because the server has closed the connection.
public boolean read(ByteBuffer byteBuffer) throws IOException {
while (byteBuffer.hasRemaining()) {
int len = socketChannel.read(byteBuffer);
if (len == 0) {
return false;
}
if (len < 0) {
throw new EOFException();
}
}
return true;
}
source
share