Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

UdpClient.DontFragment Property

Gets or sets a Boolean value that specifies whether the UdpClient allows Internet Protocol (IP) datagrams to be fragmented.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)

public bool DontFragment { get; set; }

Property Value

Type: System.Boolean
true if the UdpClient allows datagram fragmentation; otherwise, false. The default is true.

ExceptionCondition
NotSupportedException

This property can be set only for sockets that use the InterNetwork flag or the InterNetworkV6 flag.

Datagrams require fragmentation when their size exceeds the Maximum Transfer Unit (MTU) of the transmission medium. Datagrams may be fragmented by the sending host or by an intermediate router. If a datagram must be fragmented, and the DontFragment option is set, the datagram is discarded, and an Internet Control Message Protocol (ICMP) error message is sent back to the sender of the datagram.

The following code example shows the use of the DontFragment property.

public static void GetSetDontFragment(UdpClient u)
{
    // Set the don't fragment flag for packets emanating from 
    // this client.
    u.DontFragment = true;
    Console.WriteLine("DontFragment value is {0}",
        u.DontFragment);
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft