DatagramSocketControl DatagramSocketControl DatagramSocketControl DatagramSocketControl Class

Definition

Provides socket control data on a DatagramSocket object.

public : sealed class DatagramSocketControl : IDatagramSocketControl, IDatagramSocketControl2, IDatagramSocketControl3public sealed class DatagramSocketControl : IDatagramSocketControl, IDatagramSocketControl2, IDatagramSocketControl3Public NotInheritable Class DatagramSocketControl Implements IDatagramSocketControl, IDatagramSocketControl2, IDatagramSocketControl3// You can use this class in JavaScript.
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.

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.
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
bool currentSetting = clientSocket.Control.QualityOfService;

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

// Now you can call the ConnectAsync method 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 
bool 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

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

public : PlatForm::Boolean DontFragment { get; set; }public bool DontFragment { get; set; }Public ReadWrite Property DontFragment As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

Whether the DatagramSocket allows datagrams to be fragmented.

true if the DatagramSocket shouldn't fragment datagrams; otherwise, false. The default is false which allows datagrams to be fragmented.

Remarks

The DontFragment property lets your app decide whether the DatagramSocket allows datagrams to be fragmented. The default value is false which allows datagrams to be fragmented.

IP datagrams used by UDP require fragmentation when their size exceeds the Maximum Transfer Unit (MTU) of the network transmission hardware. Datagrams may be fragmented by the sending app or by an intermediate router (IPv4 only). If a datagram must be fragmented, and the DontFragment property is set to true, the datagram is discarded, and an Internet Control Message Protocol (ICMP) error message is sent back to the sender of the datagram.

This property may be set before the DatagramSocket is bound or connected. After the DatagramSocket is bound or connected, setting this property will result in an error.

See Also

InboundBufferSizeInBytes InboundBufferSizeInBytes InboundBufferSizeInBytes InboundBufferSizeInBytes

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

public : unsigned int InboundBufferSizeInBytes { get; set; }public uint InboundBufferSizeInBytes { get; set; }Public ReadWrite Property InboundBufferSizeInBytes As uint// You can use this property in JavaScript.
Value
unsigned int uint uint uint

The size, in bytes, of the buffer used for receiving data on the DatagramSocket object.

Remarks

The InboundBufferSizeInBytes property sets the value of the SO_RCVBUF socket option on the TCP socket used by the DatagramSocket. The default value is the local computer's default receive buffer size. For more detailed information, see SOL_SOCKET Socket Options in the Windows Sockets documentation.

This property may be set before the DatagramSocket is bound or connected. After the DatagramSocket is bound or connected, setting this property will result in an error.

See Also

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.

public : PlatForm::Boolean MulticastOnly { get; set; }public bool MulticastOnly { get; set; }Public ReadWrite Property MulticastOnly As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

Setting this property to true enables the DatagramSocket instance to share its local port with any Win32 sockets that are bound using SO_REUSEADDR/SO_REUSE_MULTICASTPORT, and with any other DatagramSocket instances that have MulticastOnly set to true.

See Also

OutboundUnicastHopLimit OutboundUnicastHopLimit OutboundUnicastHopLimit OutboundUnicastHopLimit

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

public : byte OutboundUnicastHopLimit { get; set; }public byte OutboundUnicastHopLimit { get; set; }Public ReadWrite Property OutboundUnicastHopLimit As byte// You can use this property in JavaScript.
Value
byte byte byte byte

The hop limit on an outbound packet sent by the DatagramSocket object. The default is 128.

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

This OutboundUnicastHopLimit property is the hop limit set on an outbound datagram packet sent to a unicast IP address using the DatagramSocket object. This property is used to set the Time to Live (TTL) field in an IPv4 packet header. This property is used to set the Hop Limit field in an IPv6 header. The default value for this property is 128.

This 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.

Setting the OutboundUnicastHopLimit may not have an effect if the system doesn't support setting the TTL.

See Also

QualityOfService QualityOfService QualityOfService QualityOfService

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

public : SocketQualityOfService QualityOfService { get; set; }public SocketQualityOfService QualityOfService { get; set; }Public ReadWrite Property QualityOfService As SocketQualityOfService// You can use this property in JavaScript.
Value
SocketQualityOfService SocketQualityOfService SocketQualityOfService SocketQualityOfService

The quality of service on a DatagramSocket object. The default is normal.

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

This QualityOfService property is the quality of service that DatagramSocket object should provide. The default value is normal.

When the property is set to a value other than normal, the socket will follow a policy to provide the specified quality of service. When the property is set to lowLatency, this sets the thread priority of the incoming packets to a higher value. The lowLatency value would commonly be used for audio or similar apps that are timing sensitive. This property is not normally set for other apps.

This property may be set before the DatagramSocket is bound or connected. After the DatagramSocket is bound or connected, setting this property will result in an error.

See Also

See Also