private int ReadCRLF(byte[] buffer) {
GlobalLog.Enter("ConnectStream#" + ValidationHelper.HashString(this) + "::ReadCRLF");
int offset = 0;
int size = NclConstants.CRLF.Length;
int BytesRead = FillFromBufferedData(buffer, ref offset, ref size);
if (BytesRead >= 0 && BytesRead != NclConstants.CRLF.Length)
{
do {
int bytesTransferred = m_Connection.Read(buffer, offset, size);
if (bytesTransferred <= 0) {
GlobalLog.Leave("ConnectStream#" + ValidationHelper.HashString(this) + "::ReadCRLF", bytesTransferred);
throw new IOException(SR.GetString(SR.net_io_readfailure, SR.GetString(SR.net_io_connectionclosed)));
}
else {
size -= bytesTransferred;
offset += bytesTransferred;
}
} while ( size > 0 );
}
GlobalLog.Leave("ConnectStream#" + ValidationHelper.HashString(this) + "::ReadCRLF", BytesRead);
return BytesRead;
}