public void Accept() { closed = false; try { if (serverSocket == null) { //commented by shariq //temp_tcpListener = new System.Net.Sockets.TcpListener(System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList[0], port); //listen on all adapters var temp_tcpListener = new System.Net.Sockets.TcpListener(System.Net.IPAddress.Parse("0.0.0.0"), port); temp_tcpListener.Start(); serverSocket = temp_tcpListener; } while (true) { var socket = serverSocket.AcceptTcpClient(); connectionListener.OnConnect(new TcpConnection(socket)); } } catch (System.IO.IOException e) { if (!closed) { throw new FastConnectionException(e); } } }
public void Accept() { _closed = false; try { if (_serverSocket == null) { //commented by shariq //tmp = new System.Net.Sockets.TcpListener(System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList[0], port); //listen on all adapters var tmp = new TcpListener(IPAddress.Parse("0.0.0.0"), _port); tmp.Start(); _serverSocket = tmp; } while (!_closed) { TcpClient socket = _serverSocket.AcceptTcpClient(); _connectionListener.OnConnect(new TcpConnection(socket)); } } catch (IOException e) { if (!_closed) { throw new FastConnectionException(e); } } }
public virtual void Accept() { if (!(connections.Count == 0)) { lock (this) { object tempObject = connections[0]; connections.RemoveAt(0); var connection = (Connection)tempObject; listener.OnConnect(connection); } } }