DatagramSocketControl DatagramSocketControl DatagramSocketControl DatagramSocketControl DatagramSocketControl Class

Definition

Provides socket control data on a DatagramSocket object.

public : sealed class DatagramSocketControl : IDatagramSocketControl, IDatagramSocketControl2, IDatagramSocketControl3
struct winrt::Windows::Networking::Sockets::DatagramSocketControl : IDatagramSocketControl, IDatagramSocketControl2, IDatagramSocketControl3
public sealed class DatagramSocketControl : IDatagramSocketControl, IDatagramSocketControl2, IDatagramSocketControl3
Public NotInheritable Class DatagramSocketControl Implements IDatagramSocketControl, IDatagramSocketControl2, IDatagramSocketControl3
// 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 DatagramSocketControl class provides access to advanced socket control data on a DatagramSocket object.

A DatagramSocketControl object is automatically created with the parent DatagramSocket object. The DatagramSocket.Control property provides access to the associated DatagramSocketControl object.

The OutboundUnicastHopLimit property can be set before or after the DatagramSocket is bound or connected. Before changing this value on a bound or connected DatagramSocket, any outgoing packets should first be flushed to ensure that all previously-written data is sent out with the previous hop limit.

Any changes to the other property values on the DatagramSocketControl must be set before the DatagramSocket is bound or connected. As a result if you need to make changes to the DontFragment, InboundBufferSizeInBytes, or QualityOfService properties, then these changes must occur before a successful call to the BindEndpointAsync, BindServiceNameAsync, or one of the ConnectAsync methods on the DatagramSocket.

The following example creates a DatagramSocket, and then demonstrates how to set the QualityOfService property to LowLatency. Other properties may be set in a similar manner. After this is done, the app can connect the DatagramSocket or send data on the socket.

using Windows.Networking.Sockets;

DatagramSocket clientSocket = new DatagramSocket();

// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting.
var currentSetting = clientSocket.Control.QualityOfService;

// Set QualityOfService to LowLatency.
clientSocket.Control.QualityOfService = SocketQualityOfService.LowLatency;

// Now you can call the ConnectAsync method to connect the DatagramSocket.
#include <winrt/Windows.Networking.Sockets.h>
using namespace winrt;
...
Windows::Networking::Sockets::DatagramSocket clientSocket;

// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting.
auto currentSetting{ clientSocket.Control().QualityOfService() };

// Set QualityOfService to LowLatency.
clientSocket.Control().QualityOfService(Windows::Networking::Sockets::SocketQualityOfService::LowLatency);

// Now you can call the ConnectAsync function to connect the DatagramSocket.
using namespace Windows::Networking::Sockets;

DatagramSocket^ clientSocket = ref new DatagramSocket();

// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting.
auto currentSetting = clientSocket->Control->QualityOfService;

// Set QualityOfService to LowLatency.
clientSocket->Control->QualityOfService = SocketQualityOfService::LowLatency;

// Now you can call the ConnectAsync method to connect the DatagramSocket.
var clientSocket = new Windows.Networking.Sockets.DatagramSocket();

// Get the current setting for this option
// This isn't required, but it shows how to get the current setting
var currentSetting = clientSocket.Control.QualityOfService; 

// Set QualityOfService to lowLatency
clientSocket.control.QualityOfService = SocketQualityOfService.lowLatency;

// Now you can call the ConnectAsync method to connect the DatagramSocket.

For more information on using DatagramSocketControl, see How to use advanced socket controls and How to use advanced socket controls .

Properties

DontFragment DontFragment DontFragment DontFragment DontFragment

Gets or sets a Boolean value that specifies whether the DatagramSocket allows IP datagrams for UDP to be fragmented.

InboundBufferSizeInBytes InboundBufferSizeInBytes InboundBufferSizeInBytes InboundBufferSizeInBytes InboundBufferSizeInBytes

Gets or sets the size, in bytes, of the buffer used for receiving data on the DatagramSocket object.

MulticastOnly MulticastOnly MulticastOnly MulticastOnly MulticastOnly

Gets or sets a Boolean value that specifies whether the DatagramSocket is able to coexist with other Win32 or WinRT multicast sockets bound to the same address/port.

OutboundUnicastHopLimit OutboundUnicastHopLimit OutboundUnicastHopLimit OutboundUnicastHopLimit OutboundUnicastHopLimit

Gets or sets the hop limit on an outbound packet sent to a unicast IP address by the DatagramSocket object.

QualityOfService QualityOfService QualityOfService QualityOfService QualityOfService

Gets or sets the quality of service on a DatagramSocket object.

See Also