| Author |
Send messages to clients selectively?
|
Yingie Pitts
Ranch Hand
Joined: Oct 10, 2002
Posts: 37
|
|
|
I used BufferedWriter.flush() to send clients messages that the server read in from one client. But this sends the message to every socket-connected client. How can I send a message to a particular client(s)? Help, please.
|
"To err is human, but to really foul things up you need a computer." Paul Ehrlich.
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8265
|
|
|
Can you share some more information? How you are keeping track of client connections? Are you using java.net.MulticastSocket?
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
Yingie Pitts
Ranch Hand
Joined: Oct 10, 2002
Posts: 37
|
|
|
No I am not using java.net.MulticastSocket. I am keeping an ArrayList of client socket objects on the server socket. Everytime a client logs in, the client notify the server to add one more client connection into the ArrayList. This is how I keep tract of my client connections.
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8265
|
|
|
OK, so at some point you must iterate through this ArrayList, opening an OutputStream (and BufferedOutputStream) on each, and writing the data to each socket in turn, right?
|
 |
 |
|
|
subject: Send messages to clients selectively?
|
|
|