Bagikan melalui


PingReply.Buffer Properti

Definisi

Mendapatkan buffer data yang diterima dalam pesan balasan gema Internet Control Message Protocol (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()

Nilai Properti

Byte[]

Array Byte yang berisi data yang diterima dalam pesan balasan gema ICMP, atau array kosong, jika tidak ada balasan yang diterima.

Contoh

Contoh kode berikut mengirimkan permintaan gema ICMP secara sinkron dan menampilkan ukuran buffer yang dikembalikan oleh properti ini.

void ComplexPing()
{
   Ping ^ pingSender = gcnew Ping;
   
   // Create a buffer of 32 bytes of data to be transmitted.
   String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
   array<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 = gcnew 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 );
   }
}
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);
    }
}

Keterangan

Buffer data yang dikirim dengan permintaan gema ICMP dikembalikan ke pengirim dalam balasan echo sehingga waktu perjalanan pulang pergi untuk paket dengan ukuran yang diketahui dapat dihitung. Buffer data, dikombinasikan dengan DontFragment opsi , dapat digunakan untuk menemukan unit transmisi maksimum untuk jalur jaringan antara komputer sumber dan tujuan. Untuk informasi tambahan, lihat "Traceroute" di RFC 1574, Bagian 3.2, tersedia di https://www.ietf.org.

Buffer default yang digunakan dengan Send dan SendAsync berisi 32 byte data.

Berlaku untuk