M
Michael B Allen
Would anyone happen to know how java.nio handles the following scenario?
I read data from a SocketChannel into a ByteBuffer. Let's say that for
whatever reason the read fills the ByteBuffer to capacity. Now the buffer
has 1 whole message plus 10 bytes of another entirely different unrelated
message. I have no problem decoding the first message but then I'm left
with 10 bytes at the end of the ByteBuffer with no room to read the
remainder of the current message. Is there some way to move those bytes to
the beginning so I can read from the channel again and start decoding the
next message?
How is this scenario supposed to be handled with NIO?
What are your general impressions of NIO? I have read vague claims that it
has bugs.
Thanks,
Mike
I read data from a SocketChannel into a ByteBuffer. Let's say that for
whatever reason the read fills the ByteBuffer to capacity. Now the buffer
has 1 whole message plus 10 bytes of another entirely different unrelated
message. I have no problem decoding the first message but then I'm left
with 10 bytes at the end of the ByteBuffer with no room to read the
remainder of the current message. Is there some way to move those bytes to
the beginning so I can read from the channel again and start decoding the
next message?
How is this scenario supposed to be handled with NIO?
What are your general impressions of NIO? I have read vague claims that it
has bugs.
Thanks,
Mike