コード例 #1
0
ファイル: Socket_Socks4.cs プロジェクト: kineva1992/repos
        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();
            }
        }
コード例 #2
0
ファイル: Socket_Socks4.cs プロジェクト: kineva1992/repos
        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();
            }
        }
コード例 #3
0
        void Bind_Write_End(IAsyncResult ar)
        {
            Bind_SO stateObj = (Bind_SO)ar.AsyncState;

            try
            {
                stateObj.UpdateContext();
                NStream.EndWrite(ar);

                //------------------------------------
                // Read the response from proxy server.
                //
                NStream.BeginRead(
                    _response,
                    0,
                    8,
                    new AsyncCallback(Bind_Read_End),
                    stateObj);
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
                stateObj.SetCompleted();
            }
        }
コード例 #4
0
ファイル: Socket_Socks4.cs プロジェクト: kineva1992/repos
        override internal IAsyncResult BeginAccept(AsyncCallback callback,
                                                   object state)
        {
            CheckDisposed();

            Accept_SO stateObj = null;

            SetProgress(true);
            try
            {
                stateObj = new Accept_SO(callback, state);

                //------------------------------------
                // Read the second response from proxy server.
                //
                NStream.BeginRead(_response,
                                  0,
                                  8,
                                  new AsyncCallback(Accept_Read_End),
                                  stateObj);
            }
            catch
            {
                SetProgress(false);
                throw;
            }
            return(stateObj);
        }
コード例 #5
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();
            }
        }