Have you ever suffer that socket channel will not send all bytes out in NIO
I found that the when call the SocketChannel.write(ByteBuffer buf)even the buf.remaining() is zero, sometime the contents will not arrive the destination.Have you ever suffered it?
The last bytes never get there? If you are talking about machine-to-machine communiocations, there are several steps involved. Have you tried to use any tools, like Ethereal, to see if it went across the wire?
When the server is not busy, all bytes will get to the destination machine.
But if the server is busy, 1% or less will disappear.
It's so strange.
For an example:
while(buffer.remaining()>0)
socketChannel.write(buffer);
The real code is not like this. The real code will depend on the selector to call the write function.