-api-id | -api-type |
---|---|
E:Windows.Networking.Sockets.DatagramSocket.MessageReceived |
winrt event |
An event that indicates that a message was received on the DatagramSocket object.
To receive data on the DatagramSocket object, an app must assign the [MessageReceived event to an event handler and then call either the BindEndpointAsync or BindServiceNameAsync method to bind the DatagramSocket to a local service name or UDP port. The ConnectAsync methods will also result in a bind operation. Writing to a stream returned by one of the GetOutputStreamAsync methods will also result in a bind operation. The MessageReceived event handler will be invoked whenever a message from a remote endpoint arrives.
To receive multicast packets on the DatagramSocket object, an app must assign the [MessageReceived event to an event handler and then call the JoinMulticastGroup method to join the multicast group.
To unregister the [MessageReceived event, the DatagramSocket object must be closed. The Close method is used by Windows app using JavaScript. For apps written using the .NET Framework 4.5 in C# and VB.NET, the Close method is exposed as the method on the DatagramSocket. For apps written in C++, the Close method will be called when using the delete keyword on the object.
DatagramSocket sample (Windows 10)
ID_CAP_NETWORKING [Windows Phone]