0
Reply

Building a server socket.

lastockler

lastockler

Dec 10 2004 6:38 AM
1.6k
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