Ejemplo n.º 1
0
        private void AcceptInboundCallback(IAsyncResult ar)
        {
            TcpClient inbound;

            try
            {
                inbound = listener.EndAcceptTcpClient(ar);
            }
            catch (Exception e)
            {
                if(e is NullReferenceException || e is ObjectDisposedException)
                    return;

                Stop();
                throw;
            }

            var proxy = new TcpProxy(inbound, outboundHost, outboundPort, inboundToOutboundDelay, outboundToInboundDelay, bufferSize);
            proxy.Connect();

            proxy.Closed += ProxyClosed;
            AddProxy(proxy);

            listener.BeginAcceptTcpClient(AcceptInboundCallback, listener);
        }