Help with Selector!

Hello everyone:If client A connects to Server, and A writes data to Server. Then if invoking Selector.select(), Selector.selectedKeys(), a SelectionKey will be get. If this happens many times, is the SelectionKey object the same one for clinet A?
[260 byte] By [Lazytiger1983a] at [2007-10-3 3:32:26]
# 1

Only if there are no other clients, otherwise it could be the key for client B, C, D, or it could be the key for the ServerSocketChannel telling you an OP_ACCEPT is ready.

SelectionKey() has methods to tell you which operation is ready and on which channel.

The SelectionKey attachment feature can also be used to associate a session context with a selection key. Such a context might include a client identifier, I/O buffers, etc.

ejpa at 2007-7-14 21:26:40 > top of Java-index,Archived Forums,Socket Programming...