A
Andersen
I am asynchronously reading into a ByteBuffer, and I then pick things
out from the buffer. I have a problem with the ByteBuffer abstraction.
Lets say the size of the ByteBuffer is 1000 bytes, and I read 800 bytes
from a socket into the ByteBuffer. I then process it, and write the
first 500 into some other place (because the 500 bytes represent some
object). Now I have 300 bytes of data in the ByteBuffer starting at
position 500 and ending at position 800. Lets say I read on the socket
into the buffer again, and say 400 bytes are ready in the Socket, but if
I read the 400 bytes into the buffer, I overflow the buffer. Yet, I am
only using 300 bytes of the buffer.
Is there a solution to this problem?
out from the buffer. I have a problem with the ByteBuffer abstraction.
Lets say the size of the ByteBuffer is 1000 bytes, and I read 800 bytes
from a socket into the ByteBuffer. I then process it, and write the
first 500 into some other place (because the 500 bytes represent some
object). Now I have 300 bytes of data in the ByteBuffer starting at
position 500 and ending at position 800. Lets say I read on the socket
into the buffer again, and say 400 bytes are ready in the Socket, but if
I read the 400 bytes into the buffer, I overflow the buffer. Yet, I am
only using 300 bytes of the buffer.
Is there a solution to this problem?