Exemplo n.º 1
0
        void Connect_Read_End(IAsyncResult ar)
        {
            Connect_SO stateObj = (Connect_SO)ar.AsyncState;

            try
            {
                stateObj.UpdateContext();
                int num = NStream.EndRead(ar);
                stateObj.ReadBytes += num;

                if (stateObj.ReadBytes < 8)
                {
                    //------------------------------------
                    // Read the response from proxy server.
                    //
                    NStream.BeginRead(_response,
                                      stateObj.ReadBytes,
                                      8 - stateObj.ReadBytes,
                                      new AsyncCallback(Connect_Read_End),
                                      stateObj);
                }
                else
                {
                    VerifyResponse();
                    stateObj.SetCompleted();
                }
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
                stateObj.SetCompleted();
            }
        }
Exemplo n.º 2
0
        void Bind_Read_End(IAsyncResult ar)
        {
            Bind_SO stateObj = (Bind_SO)ar.AsyncState;

            try
            {
                stateObj.UpdateContext();
                int num = NStream.EndRead(ar);
                stateObj.ReadBytes += num;

                if (stateObj.ReadBytes < 8)
                {
                    //------------------------------------
                    // Read the response from proxy server.
                    //
                    NStream.BeginRead(_response,
                                      stateObj.ReadBytes,
                                      8 - stateObj.ReadBytes,
                                      new AsyncCallback(Bind_Read_End),
                                      stateObj);
                }
                else
                {
                    VerifyResponse();
                    _localEndPoint  = ConstructBindEndPoint(stateObj.ProxyIP);
                    _remoteEndPoint = null;
                    stateObj.SetCompleted();
                }
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
                stateObj.SetCompleted();
            }
        }
Exemplo n.º 3
0
        void Connect_Read_End(IAsyncResult ar)
        {
            Connect_SO stateObj = (Connect_SO)ar.AsyncState;

            try
            {
                stateObj.UpdateContext();
                int num = NStream.EndRead(ar);
                stateObj.ReadBytes += num;

                if (stateObj.ReadBytes < 8)
                {
                    //------------------------------------
                    // Read the response from proxy server.
                    //
                    NStream.BeginRead(
                        _response,
                        stateObj.ReadBytes,
                        8 - stateObj.ReadBytes,
                        new AsyncCallback(Connect_Read_End),
                        stateObj);
                }
                else
                {
                    VerifyResponse();

                    //---------------------------------------
                    // I we unable to resolve remote host then
                    // store information - it will required
                    // later for BIND command.
                    if (null == stateObj.RemoteEndPoint)
                    {
                        _remotePort = stateObj.HostPort;
                        _remoteHost = stateObj.HostName;
                    }

                    stateObj.SetCompleted();
                }
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
                stateObj.SetCompleted();
            }
        }