PingOptions.DontFragment 屬性

定義

取得或設定 Boolean 值,控制是否要分割傳送到遠端主機的資料。

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

屬性值

如果無法以多個封包傳送資料則為 true,否則為 false。 預設為 false

範例

下列程式代碼範例示範如何使用建 PingOptions 構函式設定此屬性的值,然後顯示值。

// Set options for transmission:
// The data can go through 64 gateways or routers
// before it is destroyed, and the data packet
// cannot be fragmented.
PingOptions ^ options = gcnew PingOptions( 64,true );
Console::WriteLine( "Time to live: {0}", options->Ttl );
Console::WriteLine( "Don't fragment: {0}", options->DontFragment );
// Set options for transmission:
// The data can go through 64 gateways or routers
// before it is destroyed, and the data packet
// cannot be fragmented.
PingOptions options = new PingOptions (64, true);

Console.WriteLine ("Time to live: {0}", options.Ttl);
Console.WriteLine ("Don't fragment: {0}", options.DontFragment);

備註

應用程式會使用這個屬性來控制類別傳送至遠端主機 Ping 的數據是否可以分割成多個封包。 如果您想要測試用來傳輸封包之路由器和閘道的最大傳輸單位 (MTU) ,此選項會很有用。 如果這個屬性是 true ,而且傳送至遠端主機的數據較大,則傳送者與遠端主機之間的閘道或路由器 MTU 會失敗,偵測作業會失敗,狀態為 PacketTooBig

適用於