Home arrow static arrow Java Programming [Archive] - Client-to-Client chat via connection to Server
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Client-to-Client chat via connection to Server
This topic has 3 replies on 1 page.

Posts:3
Registered: 8/4/04
Client-to-Client chat via connection to Server  
Aug 4, 2004 11:44 AM



 
Hi,

I'm looking for links that might help me better understand the communication process between multi-threaded servers and the connected clients.

What I have right now is a server that allows multiple clients to connect, but all communication takes place between the client and the server.

example:

client1 says hi -> server recieves msg
server responds to client 1

client2 says hi -> server recieves msg
server responds to client2

what i want is:

client1 sends msg to server for client2
server receives msg from client1 and fwd's to client2
client2 receives msg and sends response back to server whom fwd's it back to client1.

i have a set of protocols to handle communication but i'm not sure how to write the networking side of it. how the server threads can keep track of client id's and the corresponding communication streams and when and where to write to them..

Thanks for the help.

kl365

 

Posts:14,142
Registered: 99-04-02
Re: Client-to-Client chat via connection to Server  
Aug 4, 2004 12:04 PM (reply 1 of 3)



 
a very basic idea is that you have the clients connect to the server and they pass in their ID. Then they send messages to the server which are addressed to another client's ID, and the server passes the message to the client with that ID... or replies that the ID is invalid (user not online or whatever).

The server would only write to clients when a message is addressed to them... As for connections, presumably, each client connects to the server via a TCP socket which remains open til log off. So you just hold the socket connection reference in a table with the ID. Of course, one system can only handle so many socket connections at one time, so a server farm would be needed for large scale deployments (like they'd have for AIM, Yahoo, etc).
 

Posts:3
Registered: 8/4/04
Re: Client-to-Client chat via connection to Server  
Aug 4, 2004 12:10 PM (reply 2 of 3)



 
would you be able to give me an example of how i would design the reference table?

kl365
 

Posts:14,142
Registered: 99-04-02
Re: Client-to-Client chat via connection to Server  
Aug 4, 2004 1:12 PM (reply 3 of 3)



 
java.util.HashMap users = new java.util.HashMap();
 
This topic has 3 replies on 1 page.