Socket programming: The Server <p>Ok so I've been trying to teach myself some socket programming. I wrote myself a little C# application with an async server and I understand most of it, except for the following:</p> <p>So the server has a port it listens on for connections then when it receives a connection it creates a different socket to do the communication on. This it what I dont understand... How does the communication happen between the client and the server when in theory the client has no idea what port has been elected for this new connection?</p> <p>Thanks for all your answers</p> <p>Edit: As far as I understand the listening thread listens on the default port, but all messages are then handled on a different socket for each client?</p> <p>Edit Again: Some how you guys are misunderstanding my question. I understand normal socket communication. My problem is with an async server where the listening socket is different from the connecting socket. Ie. </p> <ol> <li>Server listens on default port</li> <li>Client attrmpts to connect.</li> <li>Server receiver request.</li> <li><strong>Server then creates a communication socket between client and server and continues listening on the default port.</strong></li> </ol> <p>My problem is at the last step. How does the client now know how to communicate on the new socket? Here is some sample code <a href="http://msdn.microsoft.com/en-us/library/5w7b7x5f.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/5w7b7x5f.aspx</a></p>