Writes data to the System.Net.Sockets.NetworkStream.
- buffer
- An array of type byte that contains the data to write to the System.Net.Sockets.NetworkStream.
- offset
- The location in buffer from which to start writing data.
- size
- The number of bytes to write to the System.Net.Sockets.NetworkStream.
Type Reason ArgumentNullException buffer is null. ArgumentOutOfRangeException offset < 0.
-or-
offset > buffer.Length.
-or-
size < 0.
-or-
size > buffer.Length - offset.
System.IO.IOException Note: This method catches all exceptions thrown by the Socket.Send(Byte[], int, SocketFlags) method.ObjectDisposedException The current instance has been disposed.
The NetworkStream.Write(Byte[], int, int) method starts at the specified offset and sends size bytes from the contents of buffer to the network. The NetworkStream.Write(Byte[], int, int) method blocks until the requested number of bytes is sent or a System.Net.Sockets.SocketException is thrown. If you receive a System.Net.Sockets.SocketException, use the SocketException.ErrorCode property to obtain the specific error code, and refer to the Windows Sockets version 2 API error code documentation in MSDN for a detailed description of the error.
Check to see if the System.Net.Sockets.NetworkStream is writable by accessing the NetworkStream.CanWrite property. If you attempt to write to a System.Net.Sockets.NetworkStream that is not writable, you will get an System.IO.IOException. If you receive an System.IO.IOException, check the Exception.InnerException property to determine if it was caused by a System.Net.Sockets.SocketException.