DatagramSocketMessageReceivedEventArgs DatagramSocketMessageReceivedEventArgs DatagramSocketMessageReceivedEventArgs DatagramSocketMessageReceivedEventArgs DatagramSocketMessageReceivedEventArgs Class

Definition

Provides data for a MessageReceived event on a DatagramSocket.

public : sealed class DatagramSocketMessageReceivedEventArgs : IDatagramSocketMessageReceivedEventArgs
struct winrt::Windows::Networking::Sockets::DatagramSocketMessageReceivedEventArgs : IDatagramSocketMessageReceivedEventArgs
public sealed class DatagramSocketMessageReceivedEventArgs : IDatagramSocketMessageReceivedEventArgs
Public NotInheritable Class DatagramSocketMessageReceivedEventArgs Implements IDatagramSocketMessageReceivedEventArgs
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
ID_CAP_NETWORKING [Windows Phone]

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.

Properties

LocalAddress LocalAddress LocalAddress LocalAddress LocalAddress

Gets the local IP address associated with a DatagramSocket when a message was received.

public : HostName LocalAddress { get; }
HostName LocalAddress();
public HostName LocalAddress { get; }
Public ReadOnly Property LocalAddress As HostName
var hostName = datagramSocketMessageReceivedEventArgs.localAddress;
Value
HostName HostName HostName

The local IP address where the message was received by the DatagramSocket.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
ID_CAP_NETWORKING [Windows Phone]

Remarks

The DatagramSocketMessageReceivedEventArgs.LocalAddress property gets the local IP address where a message was received on a DatagramSocket. A message received event can only occur after a successful connect or bind operation on the DatagramSocket.

See Also

RemoteAddress RemoteAddress RemoteAddress RemoteAddress RemoteAddress

Gets the IP address of the remote sender of the datagram on the DatagramSocket when a message is received.

public : HostName RemoteAddress { get; }
HostName RemoteAddress();
public HostName RemoteAddress { get; }
Public ReadOnly Property RemoteAddress As HostName
var hostName = datagramSocketMessageReceivedEventArgs.remoteAddress;
Value
HostName HostName HostName

The IP address of the remote network destination when the message is received on a DatagramSocket.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
ID_CAP_NETWORKING [Windows Phone]

Remarks

The DatagramSocketMessageReceivedEventArgs.RemoteAddress property gets the IP address of the remote sender when a datagram was received on a DatagramSocket. A message received event can only occur after a successful connect or bind operation on the DatagramSocket.

See Also

RemotePort RemotePort RemotePort RemotePort RemotePort

Gets the UDP port number of the remote sender of the datagram received on the DatagramSocket.

public : Platform::String RemotePort { get; }
winrt::hstring RemotePort();
public string RemotePort { get; }
Public ReadOnly Property RemotePort As string
var string = datagramSocketMessageReceivedEventArgs.remotePort;
Value
string string string

The UDP port number of the remote network destination when a message is received on a DatagramSocket.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
ID_CAP_NETWORKING [Windows Phone]

Remarks

The DatagramSocketMessageReceivedEventArgs.RemotePort property gets the UDP port number of the remote sender when a datagram was received on a DatagramSocket. A message received event can only occur after a successful connect or bind operation on the DatagramSocket.

See Also

Methods

GetDataReader() GetDataReader() GetDataReader() GetDataReader() GetDataReader()

Gets a DataReader object to read incoming data received from the remote network destination on a DatagramSocket object.

public : DataReader GetDataReader()
DataReader GetDataReader() const;
public DataReader GetDataReader()
Public Function GetDataReader() As DataReader
var dataReader = datagramSocketMessageReceivedEventArgs.getDataReader();
Returns

A DataReader object to read incoming data received from the remote network destination on a DatagramSocket object.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
ID_CAP_NETWORKING [Windows Phone]
See Also

GetDataStream() GetDataStream() GetDataStream() GetDataStream() 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.

public : IInputStream GetDataStream()
IInputStream GetDataStream() const;
public IInputStream GetDataStream()
Public Function GetDataStream() As IInputStream
var iInputStream = datagramSocketMessageReceivedEventArgs.getDataStream();
Returns

An IInputStream object that represents a sequential stream of bytes to be read as a message.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
ID_CAP_NETWORKING [Windows Phone]
See Also

See Also