Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Socket.DontFragment Property

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

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

public bool DontFragment { get; set; }
/** @property */
public boolean get_DontFragment ()

/** @property */
public void set_DontFragment (boolean value)

public function get DontFragment () : boolean

public function set DontFragment (value : boolean)

Not applicable.

Property Value

true if the Socket allows datagram fragmentation; otherwise, false. The default is true.

Exception typeCondition

NotSupportedException

This property can be set only for sockets in the InterNetwork or InterNetworkV6 families.

SocketException

An error occurred when attempting to access the socket. See the Remarks section for more information.

ObjectDisposedException

The Socket has been closed.

Datagrams require fragmentation when their size exceeds the Maximum Transfer Unit (MTU) of the transmission medium. Datagrams may be fragmented by the sending host (all Internet Protocol versions) or an intermediate router (Internet Protocol Version 4 only). 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.

Setting this property on a Transmission Control Protocol (TCP) socket will have no effect.

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

static void ConfigureUdpSocket(Socket udpSocket)
{
    // set the Don't Fragment flag.
    udpSocket.DontFragment = true;
    // Enable broadcast.
    udpSocket.EnableBroadcast = true;

    // Disable multicast loopback.
    udpSocket.MulticastLoopback = false;

    Console.WriteLine("Udp Socket configured:");
    Console.WriteLine("  DontFragment {0}", 
                                        udpSocket.DontFragment);
    Console.WriteLine("  EnableBroadcast {0}", 
                                        udpSocket.EnableBroadcast);
    Console.WriteLine("  MulticastLoopback {0}", 
                                        udpSocket.MulticastLoopback);
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft