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.

Exception Condition

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}",

.NET Framework
Available since 2.0
Return to top