检测远程主机何时关闭非阻塞套接字
// Read from socket int numBytesRead = socketChannel.read(buf); /** * 时代Java公众号 - N o w J a v a . c o m 提 供 **/ if (numBytesRead == -1) { // No more bytes can be read from the channel socketChannel.close(); } else { // Read the bytes from the buffer } // Write to socket int numBytesWritten = socketChannel.write(buf);