Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DatagramSocketMessageReceivedEventArgs class

Applies to Windows and Windows Phone

Provides data for a MessageReceived event on a DatagramSocket.

Syntax


/* For information about creating or accessing this object, see Remarks. */

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Version(0x06020000)]

Members

The DatagramSocketMessageReceivedEventArgs class has these types of members:

Methods

The DatagramSocketMessageReceivedEventArgs class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
GetDataReader Gets a DataReader object to read incoming data received from the remote network destination on a DatagramSocket object.
GetDataStream Gets an IInputStream object that represents a sequential stream of bytes to be read as a message from the remote network destination on a DatagramSocket object.

 

Properties

The DatagramSocketMessageReceivedEventArgs class has these properties.

PropertyAccess typeDescription

LocalAddress

Read-onlyGets the local IP address associated with a DatagramSocket when a message was received.

RemoteAddress

Read-onlyGets the IP address of the remote sender of the datagram on the DatagramSocket when a message is received.

RemotePort

Read-onlyGets the UDP port number of the remote sender of the datagram received on the 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.

Requirements

Minimum supported client

Windows 8 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 [Windows Store apps, desktop apps]

Minimum supported phone

Windows Phone 8

Namespace

Windows.Networking.Sockets
Windows::Networking::Sockets [C++]

Metadata

Windows.winmd

DLL

Windows.Networking.dll

Capabilities

ID_CAP_NETWORKING [Windows Phone]

See also

DatagramSocket
DatagramSocket.BindServiceNameAsync
DatagramSocket.BindEndpointAsync
DatagramSocket.MessageReceived
Streams.DataReader
Streams.IInputStream
Object

 

 

Show:
© 2014 Microsoft