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