Exemplo n.º 1
0
        public Relay(string remoteIP, int remotePort, string localIP, int localPort)
        {
            this.IP = String.Format(remoteIP + ":" + remotePort);

            IPEndPoint local = new IPEndPoint(IPAddress.Parse(localIP), localPort);
            IPEndPoint remote = new IPEndPoint(IPAddress.Parse(remoteIP), remotePort);

            TcpForwarderSlim forwarder = new TcpForwarderSlim(this);

            Thread myNewThread = new Thread(() => forwarder.Start(local, remote));
            myNewThread.Start();
        }
Exemplo n.º 2
0
        public void Start(IPEndPoint local, IPEndPoint remote)
        {
            _mainSocket.Bind(local);
            _mainSocket.Listen(10);

            while (true)
            {
                var source      = _mainSocket.Accept();
                var destination = new TcpForwarderSlim();
                var state       = new State(source, destination._mainSocket);
                destination.Connect(remote, source);
                source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceiveSource, state);
            }
        }
Exemplo n.º 3
0
        public void Start(IPEndPoint local, IPEndPoint remote)
        {
            MainSocket.Bind(local);
            MainSocket.Listen(10);

            while (true)
            {
                var source = MainSocket.Accept();
                var destination = new TcpForwarderSlim(this.Relayer);
                var state = new State(source, destination.MainSocket, this.Relayer);

                destination.Connect(remote, source, this.Relayer);
                source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnSourceDataReceive, state);
            }
        }