Exemplo n.º 1
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, OnDataReceive, state);
     }
 }
Exemplo n.º 2
0
        public void Start(IPEndPoint local, IPEndPoint remote)
        {
            try
            {
                _mainSocket.Bind(local);
                _mainSocket.Listen(10);
            }
            catch (SocketException SE)
            {
                string error = "An error occured while connecting [" + SE.Message + "]\n";
                throw new Exception(error);
            }

            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, OnDataReceive, state);
            }
        }