private Socks4 CreateListener(int listeningPort) { var server = new Socks4(listeningPort, ClientConnect); server.OnSendData += OnSendData; server.OnReceiveData += OnReceiveData; server.Start(); return server; }
public Socks4Thread(TcpClient Client, Socks4.onReceiveData onReceiveData, Socks4.onSendData onSendData, Func<string, int, Socket> clientConnect) { this._server = Client; this.OnReceiveData = onReceiveData; this.OnSendData = onSendData; this._transferer = new Thread(new ThreadStart(this.TransfererThread)); this._transferer.IsBackground = true; this._transferer.Start(); _clientConnect = clientConnect; }
private void ConfigureServer() { if (_socksServer != null) { _socksServer.Stop(); _socksServer = null; } if (Port.HasValue) { if (Port.Value > 0) { _socksServer = CreateListener(Port.Value); } else { for (; ; ) { try { _socksServer = CreateListener(0); _port = _socksServer.Port; break; } catch (SocketException) { } } } } }