This code checks if there are new clients establishing a connection. If so AcceptSocket()
is called. The only problem is server must check often for a quick respond to clients.
TcpListener server = new TcpListener(localIP, port);
server.Start();
while (!shuttingDown)
{
if (server.Pending())
{
Socket client = server.AcceptSocket();
if (client != null)
{
// do client stuff
}
}
else
Thread.Sleep(1000);
}