0
Answer

Building a server socket.

lastockler

lastockler

19y
1.6k
1
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(); ...
Next Recommended Forum