Socket.DontFragment Property
Assembly: System (in System.dll)
| Exception | Condition |
|---|---|
| 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 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.
- 6/3/2011
- Dmitry Pelevin