c# how to connect multiple clients to a TcpListener

Claudia picture Claudia · Jun 24, 2012 · Viewed 27.3k times · Source

I am implementing a game in a WPF application. I need to connect at least 10 players to a server. I have always worked with only one TcpClient and one TcpListener. Is there any way to connect a lot of clients to a server? I tried to create one thread per connection, but did not work. I have searched and I couldn`t find a simple example that could teach me how to do it.

Answer

Theo picture Theo · Jun 25, 2012

Take a look at http://csharp.net-informations.com/communications/csharp-multi-threaded-server-socket.htm

If you scroll to the bottom there are other available examples, such as a TCP chat server/client which might be helpful.