/// <summary>
/// Reads data from the stream.
/// </summary>
/// <param name="buffer">The location in memory to store data read from the stream.</param>
/// <param name="offset">The location in the buffer to begin storing the data to.</param>
/// <param name="size">The number of bytes to read from the stream.</param>
/// <returns>The number of bytes read from the stream.</returns>
/// <exception cref="ArgumentNullException"><paramref name="buffer"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
/// <exception cref="ArgumentOutOfRangeException">The specified <paramref name="offset"/> or <paramref name="size"/> exceeds the size of <paramref name="buffer"/>.</exception>
/// <exception cref="IOException">There is a failure while reading from the network.</exception>
public override int Read(byte[] buffer, int offset, int size)
{
if (buffer == null)
{
throw new ArgumentNullException();
}
if (offset < 0 || offset > buffer.Length || size < 0 || size > buffer.Length - offset)
{
throw new ArgumentOutOfRangeException();
}
if (Socket == null)
{
throw new IOException();
}
return(Socket.Receive(buffer, offset, size, SocketFlags.None));
}