private ResponseDescription ReceiveCommandResponse()
{
// These are the things that will be needed to maintain state.
ReceiveState state = new ReceiveState(this);
try
{
// If a string of nonzero length was decoded from the buffered bytes after the last complete response, then we
// will use this string as our first string to append to the response StatusBuffer, and we will
// forego a Connection.Receive here.
if (_buffer.Length > 0)
{
ReceiveCommandResponseCallback(state, -1);
}
else
{
int bytesRead;
try
{
if (_isAsync)
{
BeginRead(state.Buffer, 0, state.Buffer.Length, s_readCallbackDelegate, state);
return null;
}
else
{
bytesRead = Read(state.Buffer, 0, state.Buffer.Length);
if (bytesRead == 0)
CloseSocket();
ReceiveCommandResponseCallback(state, bytesRead);
}
}
catch (IOException)
{
MarkAsRecoverableFailure();
throw;
}
catch
{
throw;
}
}
}
catch (Exception e)
{
if (e is WebException)
throw;
throw GenerateException(SR.net_ftp_receivefailure, WebExceptionStatus.ReceiveFailure, e);
}
return state.Resp;
}