UdpClient.EndSend(IAsyncResult) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Ends a pending asynchronous send.
public:
int EndSend(IAsyncResult ^ asyncResult);
public int EndSend(IAsyncResult asyncResult);
member this.EndSend : IAsyncResult -> int
Public Function EndSend (asyncResult As IAsyncResult) As Integer
- asyncResult
- IAsyncResult
An IAsyncResult object returned by a call to BeginSend.
If successful, the number of bytes sent to the UdpClient.
asyncResult
is null
.
asyncResult
was not returned by a call to the BeginSend(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) method.
EndSend(IAsyncResult) was previously called for the asynchronous read.
An error occurred when attempting to access the underlying socket.
The underlying Socket has been closed.
The following code example uses BeginSend to complete an asynchronous send of a server request.
public:
static bool isMessageSent;
static void SendCallback(IAsyncResult^ asyncResult)
{
UdpClient^ udpClient = (UdpClient^)asyncResult->AsyncState;
Console::WriteLine("number of bytes sent: {0}",
udpClient->EndSend(asyncResult));
isMessageSent = true;
}
public static bool messageSent = false;
public static void SendCallback(IAsyncResult ar)
{
UdpClient u = (UdpClient)ar.AsyncState;
Console.WriteLine($"number of bytes sent: {u.EndSend(ar)}");
messageSent = true;
}
This method blocks until the operation is complete.
To perform this operation synchronously, use the Send method.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: