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

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

                if (stateObj.ReadBytes < 8)
                {
                    //------------------------------------
                    // Continue read the response from proxy server.
                    //
                    NStream.BeginRead(_response,
                                      stateObj.ReadBytes,
                                      8 - stateObj.ReadBytes,
                                      new AsyncCallback(Accept_Read_End),
                                      stateObj);
                }
                else
                {
                    VerifyResponse();
                    stateObj.SetCompleted();
                }
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
                stateObj.SetCompleted();
            }
        }
        private void Accept_Read_End(IAsyncResult ar)
        {
            Accept_SO asyncState = (Accept_SO)ar.AsyncState;

            try
            {
                asyncState.UpdateContext();
                asyncState.ReadBytes += base.NStream.EndRead(ar);
                if (asyncState.ReadBytes < 8)
                {
                    base.NStream.BeginRead(this._response, asyncState.ReadBytes, 8 - asyncState.ReadBytes, new AsyncCallback(this.Accept_Read_End), asyncState);
                }
                else
                {
                    this.VerifyResponse();
                    asyncState.SetCompleted();
                }
            }
            catch (Exception exception)
            {
                asyncState.Exception = exception;
                asyncState.SetCompleted();
            }
        }
        private void Accept_Read_End(IAsyncResult ar)
        {
            Accept_SO asyncState = (Accept_SO)ar.AsyncState;

            try
            {
                asyncState.UpdateContext();
                byte[] reply = this.EndReadVerifyReply(ar);
                this._remoteEndPoint = this.ExtractReplyAddr(reply);
            }
            catch (Exception exception)
            {
                asyncState.Exception = exception;
            }
            asyncState.SetCompleted();
        }