Search code examples
c#asyncsocket

Client Server Relationship Confusion


I have 5 computers that control different hardware. One of the five is the main controller for the other 4. I need to send commands from the main controller to the 4 slave controllers over TCPIP. I have very limited experience with Socket programming.

In the system I have which would be the client and which would be the server? It would seem to me that in the configuration I have the line between server and client may be skewed. Both sides need to send and receive commands, is there really a separation of client and server or is that just the convention? Can I have both endpoints as a client and server at the same time using the same socket? Essentially can I have both ends listening and sending requests?

I'm referencing the example code on MSN.

Asynchronous Server Socket

Asynchronous Client Socket


Solution

  • As far as socket connections go, who is the client and who is the server is just a matter of who accepts connections (the server) and who initiates a connect request (the client).

    Once the connection is established, traffic can go in either direction (both client and server can send and/or receive data).