Edit

Share via


UdpClient.DontFragment Property

Definition

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

public:
 property bool DontFragment { bool get(); void set(bool value); };
public bool DontFragment { get; set; }
member this.DontFragment : bool with get, set
Public Property DontFragment As Boolean

Property Value

true if the UdpClient doesn't allow datagram fragmentation; otherwise, false. The default is true.

Exceptions

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

Examples

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

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 );
}
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);
}

Remarks

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.

Applies to