Help with ByteBuffer usage in nonblocking TCP programming!

Hello everyone,

I am trying to write a server which uses Selector.

My Problem is , when Selector detects that a SocketChannel has new data,what will happen if the data isn't fully transferred to SocketChannel. E.g I want 10 bytes data, but read method only returns 5.

How can I solve this problem?

Thanks.

[337 byte] By [Lazytiger1983a] at [2007-10-3 3:24:49]
# 1
Wait for OP_READ and read again. Repeat until you have enough.
ejpa at 2007-7-14 21:17:39 > top of Java-index,Archived Forums,Socket Programming...
# 2
Thanks. I know how to do now.
Lazytiger1983a at 2007-7-14 21:17:39 > top of Java-index,Archived Forums,Socket Programming...