Beispiel #1
0
        public void Start()
        {
            MainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            MainSocket.Bind(new IPEndPoint(IPAddress.Parse("127.0.0.1"), Forwarding));
            MainSocket.Listen(10);

            Task.Run(() =>
            {
                try
                {
                    while (true)
                    {
                        var source = MainSocket.Accept();
                        Sockets.Add(source);
                        var destination = new TcpProxy();
                        Sockets.Add(destination.MainSocket);
                        var state = new State(source, destination.MainSocket);
                        destination.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), toPort), source);
                            #if DNX451
                        source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state);
                            #endif
                    }
                }
                catch
                {
                }
            });
        }
        public void Start()
        {       
            MainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            MainSocket.Bind(new IPEndPoint(IPAddress.Parse("127.0.0.1"), Forwarding));
            MainSocket.Listen(10);

            Task.Run(() =>
                {
                    try
                    {
                        while (true)
                        {
                            var source = MainSocket.Accept();
                            Sockets.Add(source);
                            var destination = new TcpProxy();
                            Sockets.Add(destination.MainSocket);
                            var state = new State(source, destination.MainSocket);
                            destination.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), toPort), source);
                            source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state);
                        }
                    }
                    catch
                    {

                    }
                });
        }