Chat program: how server distinguishes each client connected to it
My task is to make a conference chat program with GUI wherein several clients may connect to the server.
I'm just starting to develop my code and I'm stuck with these problems:
One client sends a message to the server by pushing the button 'SEND'. The task of the server is to send this message to all clients connected to it.
Each of the clients has a name (i.e. Client1, Client2). How will the server know which of the clients sent a message because the server needs to send this message to the clients:
(for example Client1 was the one who sent the message)
Is there a way for the server to distinguish between the sockets connected to it, send messages to all the sockets connected to it, and choose a particular socket to send a message?
Thanks for the future help! :)