Problem with Java selector/SocketChannel?

The data could be waiting in a buffer waiting to be filled to be sent. Edit: You set the SocketChannel to non-blocking mode, so you're right to assume that takes care of flushing on the sending side, I assume the client do not buffer their input? The problem might be that SocketChannel.write() is not garantueed to write the whole buffer, but might return early.

You need to wrap writes in a while loop to keeping track of bytes written to make sure your data is actually written to the channel. To quote the Javadoc: Unless otherwise specified, a write operation will return only after writing all of the r requested bytes. Some types of channels, depending upon their state, may write only some of the bytes or possibly none at all.

A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer.

As you can see in the code, I'm using ByteBuffers to hold the data. I was under the impression that I didn't need to flush them, just use sc.write() to send the data in the buffer? – Jacob_ Jan 31 '10 at 22:47.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions