Is it possible AcceptSocketin an object TcpListenerwith timeouts to interrupt after a while?
TcpListener server = new TcpListener(localIP, port);
server.Start();
while (!shuttingDown)
try
{
Socket client = server.AcceptSocket();
if (client != null)
{
// do client stuff
}
}
catch { }
Trying BeginAccept and EndAccept: how can I end the reception if there is no client for 3 seconds? (I'm trying to approximate the solution here)
server.BeginAcceptTcpClient(new AsyncCallback(DoAcceptTcpClientCallback), server);
Thread.Sleep(3000);
server.EndAcceptTcpClient(???);
source
share