Building a server socket.
This piece of code runs inside a thread and I want introduce a timeout to Accept method.
How can I do this?
I want abort this thread but I can't while this listener is waiting an external connection.
Socket handler;
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);
Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
try
{
listener.Bind(localEndPoint);
listener.Listen(10);
while(true)
{
handler = listener.Accept();
...