Handles the end of an asynchronous write.
Assembly: System (in System.dll)
The asyncResult parameter is null.
The underlying Socket is closed.
An error occurred while writing to the network.
An error occurred when accessing the socket. See the Remarks section for more information.
The NetworkStream is closed.
completes the asynchronous send operation started in BeginWrite.
Before calling BeginWrite, you need to create a callback method that implements the AsyncCallback delegate. This callback method executes in a separate thread and is called by the system after BeginWrite returns. The callback method must accept the IAsyncResult returned from the BeginWrite method as a parameter.
Within the callback method, call the AsyncState property of the IAsyncResult parameter to obtain the NetworkStream. After obtaining the NetworkStream, you can call the method to successfully complete the send operation and return the number of bytes sent.
The method blocks until the requested number of bytes are sent.
If you receive an IOException, check the InnerException property to determine if it was caused by a SocketException. If so, use the 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.