I have some question about socket programming, clarify me if I have any misunderstanding
Say if I want to build a multi-client IM like this one:http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/socket.html
, the Example 2: Multithreaded Server Example
What I’m able to do is, every client can send a message to the server. And the server receives those messages sent by all clients. Every client receives his OWN response reply by the server.
But this is not IM means. IM means client can talk to client. But with my code, that’s only every client talk to the server separately. I would like to know how to write the code such that client can pass a message to the server. The server then broadcast that message to all clients to let them see.
As my code, everything starts from the clients’ action. But if I want to notify other client (recipient) that a message appears, it somehow needs to trigger by the server.
What is the proper way to make a communication between clients?
This may be naïve for you, or I didn’t explain the question well. Anyway, any advices are welcome.