This topic has not yet been rated - Rate this topic

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
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, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Mistake in description?
DontFragment is "true if the UdpClient  allows datagram fragmentation; otherwise, false. The default is true."

1. What's the contradiction?
2. Debugger shows that the default is false.