UdpClient.DontFragment UdpClient.DontFragment UdpClient.DontFragment UdpClient.DontFragment Property

定義

取得或設定 Boolean 值,指定 UdpClient 是否允許將網際網路通訊協定 (IP) 資料包分散。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

屬性值

如果 UdpClient 允許資料包分散,則為 true,否則為 falsetrue if the UdpClient allows datagram fragmentation; otherwise, false. 預設為 trueThe default is true.

例外狀況

只可以為使用 InterNetwork 旗標或 InterNetworkV6 旗標的通訊端設定這個屬性。This property can be set only for sockets that use the InterNetwork flag or the InterNetworkV6 flag.

範例

下列程式碼範例示範如何使用DontFragment屬性。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);
}

備註

當資料包的大小超過傳輸媒體的最大傳輸單位 (MTU) 時, 就需要片段。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. 如果資料包必須分散, 而且已設定DontFragment此選項, 則會捨棄資料包, 並將網際網路控制訊息通訊協定 (ICMP) 錯誤訊息傳送回資料包的寄件者。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.

適用於