internal virtual IAsyncResult UnsafeBeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, Object state)
{
if (m_CleanedUp)
{
throw new ObjectDisposedException(GetType().FullName);
}
if (!CanRead)
{
throw new InvalidOperationException(SR.GetString(SR.net_writeonlystream));
}
Socket chkStreamSocket = m_StreamSocket;
if (chkStreamSocket == null)
{
throw new IOException(SR.GetString(SR.net_io_readfailure, SR.GetString(SR.net_io_connectionclosed)));
}
try
{
IAsyncResult asyncResult = chkStreamSocket.UnsafeBeginReceive(
buffer,
offset,
size,
SocketFlags.None,
callback,
state);
return(asyncResult);
}
catch (Exception exception)
{
if (NclUtilities.IsFatal(exception))
{
throw;
}
//
// some sort of error occured on the socket call,
// set the SocketException as InnerException and throw
//
throw new IOException(SR.GetString(SR.net_io_readfailure, exception.Message), exception);
}
catch {
//
// some sort of error occured on the socket call,
// set the SocketException as InnerException and throw
//
throw new IOException(SR.GetString(SR.net_io_readfailure, string.Empty), new Exception(SR.GetString(SR.net_nonClsCompliantException)));
}
}