Originally posted by dragondad
Is it possible to have multiple client "c" programs communicating to the same server using the same socket. If so, how does the server know which client to send a message back to.
If somebody could illustrate this in linux "C" code I would very much appreciate it.
There are probably several ways to do this, but in a simple scenario, the server listens to the port via accept(). When a connection arrives, the accept() call returns and you have a socket for communication with the client. You fork() a child to handle the communication, while the parent goes back to accept() another connection.
I don't have any C code on hand with an example, but I have some python code that illustrates it.