語言

PingReply.Buffer 屬性

定義

取得網際網路控制訊息協定(ICMP)回聲回覆訊息中接收的資料緩衝區。

public:
 property cli::array <System::Byte> ^ Buffer { cli::array <System::Byte> ^ get(); };
public byte[] Buffer { get; }
member this.Buffer : byte[]
Public ReadOnly Property Buffer As Byte()

屬性值

Byte[]

Byte包含 ICMP 回波回覆訊息中資料的陣列,若未收到回覆則為空陣列。

範例

以下程式碼範例同步發送 ICMP 回波請求,並顯示此特性回傳的緩衝區大小。

public static void ComplexPing ()
{
    Ping pingSender = new Ping ();

    // Create a buffer of 32 bytes of data to be transmitted.
    string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    byte[] buffer = Encoding.ASCII.GetBytes (data);

    // Wait 10 seconds for a reply.
    int timeout = 10000;

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

    // Send the request.
    PingReply reply = pingSender.Send ("www.contoso.com", timeout, buffer, options);

    if (reply.Status == IPStatus.Success)
    {
        Console.WriteLine ("Address: {0}", reply.Address.ToString ());
        Console.WriteLine ("RoundTrip time: {0}", reply.RoundtripTime);
        Console.WriteLine ("Time to live: {0}", reply.Options.Ttl);
        Console.WriteLine ("Don't fragment: {0}", reply.Options.DontFragment);
        Console.WriteLine ("Buffer size: {0}", reply.Buffer.Length);
    }
    else
    {
        Console.WriteLine (reply.Status);
    }
}

備註

隨 ICMP 回波請求傳送的資料緩衝區會在回波回覆中回傳給發送端,以便計算已知大小封包的往返傳輸時間。 資料緩衝區結合選項 DontFragment ,可用來發現來源與目的電腦間網路路徑的最大傳輸單元。 欲了解更多資訊,請參閱RFC 1574第3.2節中的「Traceroute」條目,可 https://www.ietf.org於 。

預設緩衝區與 SendSendAsync 及 含有 32 位元組資料。

適用於