Hey everyone, I am currently working on a MultiServer class which creates looks for new connections from any client class and creates a thread so that each client can run at the "same time". The client sends data to the server and the server just echos back to that client that sent the data; and does this for all the other clients.
I am writing this post because my main goal is to have a different functionality rather than the 'echo' nature described above. I would like to have any one client to send data to the server and for the server to send the data to all the other clients connected. My first idea was to have a linked list for the server so that every time a new connection occurs, the linked list grows. My first problem that I noticed was when I thought of the following example:
Say there were three clients and client 2 sent data. I could 'walk down' the list until I get to the data field that sent the data and then send to client 3 by moving the pointer. How would I send the data to client 1?
Im sure the above paragraph didnt make sense and am hoping that someone could guide me on how I could send text from one client to other clients.
NB: I do not require any code, all i am asking is someone to help explain how to do my above question!