Beispiel #1
0
        public void Start(IPEndPoint local, IPEndPoint remote_address)
        {
            MainSocket.Bind(local);
            MainSocket.Listen(10);

            dic_EndPoint_Domain.Add("127.0.0.1:9002", "amiss.com");
            dic_EndPoint_Domain.Add("127.0.0.1:9009", "id.ifc.com");

            Task.Factory.StartNew((object sok) =>
            {
                Socket m_socket = sok as Socket;

                Console.WriteLine("Opening: 127.0.0.1:9002 ... ");

                while (true)
                {
                    var source        = m_socket.Accept();
                    var destination   = new TcpForwarderSlim();
                    var state         = new State(source, destination.MainSocket);
                    IPEndPoint remote = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9002);
                    destination.Connect(remote, source);
                    source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state);
                }
            }, MainSocket);


            Task.Factory.StartNew((object sok) =>
            {
                Socket m_socket = sok as Socket;

                Console.WriteLine("Opening: 127.0.0.1:9009 ... ");

                while (true)
                {
                    var source        = m_socket.Accept();
                    var destination   = new TcpForwarderSlim();
                    var state         = new State(source, destination.MainSocket);
                    IPEndPoint remote = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9009);
                    destination.Connect(remote, source);
                    source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state);
                }
            }, MainSocket);
        }
Beispiel #2
0
        public void Start(IPEndPoint local, IPEndPoint remote)
        {
            MainSocket.Bind(local);
            MainSocket.Listen(10);

            Console.WriteLine("Opening ... ");

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

                string line = System.Text.Encoding.ASCII.GetString(state.Buffer);

                destination.Connect(remote, source);

                string line2 = System.Text.Encoding.ASCII.GetString(state.Buffer);

                source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state);
            }
        }