BytesRoad.Net.Sockets.Socket_Socks4.Connect_Read_End C# (CSharp) Method

Connect_Read_End() private method

private Connect_Read_End ( IAsyncResult ar ) : void
ar IAsyncResult
return void
        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();
            }
        }