private void ListenThread(object state) { var callback = (SocketConnectionAccepted)state; try { while (!_disconnect) { _listener.Server.Poll(500000, SelectMode.SelectRead); if (_disconnect) { break; } // Accept new clients while (_listener.Pending()) { var socket = _listener.AcceptSocket(); var imp = new PoolSocket(socket); Console.WriteLine(imp.GetRemoteAddress() + " is connecting..."); callback(imp); } } } catch (Exception ex) { Console.WriteLine($"{nameof(ListenThread)} terminated with exception\n{ex}"); } }
private void ListenThread(object state) { var callback = (SocketConnectionAccepted)state; try { while (!_disconnect) { _listener.Server.Poll(500000, SelectMode.SelectRead); if (_disconnect) break; // Accept new clients while (_listener.Pending()) { var socket = _listener.AcceptSocket(); var imp = new PoolSocket(socket); Console.WriteLine(imp.GetRemoteAddress() + " is connecting..."); callback(imp); } } } catch (Exception ex) { Console.WriteLine($"{nameof(ListenThread)} terminated with exception\n{ex}"); } }