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();
}
}