Java NIO question...

Hey, I've just start reading and programming a client/server using NIO and got to a point where i need to keep a list of connected clients to send them messages as the server processes information it received... How could i handle this selection of clients that i want to send a specific message and how should I store those clients after they connect (I mean, when a client connects, a channel is started, but how can i identify later that a channel is related to THAT client?)

Thanks in advance

Message was edited by:

Lemmerich

[557 byte] By [Lemmericha] at [2007-10-2 21:36:24]
# 1
Well, you must have someway of identifying the client once he connects. Store each channel in a HashMap using the client identifier as the key.
Jasprea at 2007-7-14 0:50:35 > top of Java-index,Core,Core APIs...
# 2
Generally you will associate some kind of client session object with the channel via the attachment. This will also contain the input buffer and whatever you need in your application to identify the client.
ejpa at 2007-7-14 0:50:35 > top of Java-index,Core,Core APIs...
# 3
Yea, thanks for the answers. The attachment thing will just do what i wanted =DThks
Lemmericha at 2007-7-14 0:50:35 > top of Java-index,Core,Core APIs...