Skip to content

Latest commit

 

History

History
37 lines (22 loc) · 3.04 KB

datagramsocketmessagereceivedeventargs.md

File metadata and controls

37 lines (22 loc) · 3.04 KB
-api-id -api-type
T:Windows.Networking.Sockets.DatagramSocketMessageReceivedEventArgs
winrt class

Windows.Networking.Sockets.DatagramSocketMessageReceivedEventArgs

-description

Provides data for a MessageReceived event on a DatagramSocket.

-remarks

The DatagramSocketMessageReceivedEventArgs is used to receive data on a DatagramSocket object.

The DatagramSocket.BindServiceNameAsync or DatagramSocket.BindEndpointAsync method is used to bind a DatagramSocket to a local service name or UDP port if a DatagramSocket instance wants to listen and receive data. These methods are not needed if the DatagramSocket is to be used only for sending data.

A DatagramSocket.MessageReceived event occurs on a DatagramSocket that has been bound to a local service name or UDP port when a message is received. A DatagramSocketMessageReceivedEventArgs instance is created when the DatagramSocket.MessageReceived event occurs.

There are two primary methods to read data when a message has been received:

  • The GetDataStream method returns a Streams.IInputStream object that represents a sequential stream of bytes in the received message. The app must then parse the received stream of bytes.
  • The GetDataReader method returns a Streams.DataReader object to read incoming data. The Streams.DataReader object has separate methods to read the data in a variety of formats including bytes, signed and unsigned integers, boolean values, single and double floating point numbers, strings, date time and time span values, GUIDs, and buffers. These methods can be used directly to parse the received message.

-examples

-see-also

DatagramSocket, DatagramSocket.BindServiceNameAsync, DatagramSocket.BindEndpointAsync, DatagramSocket.MessageReceived, Streams.DataReader, Streams.IInputStream, DatagramSocket sample (Windows 10), DatagramSocket sample

-capabilities

ID_CAP_NETWORKING [Windows Phone]