Share via


PingReply.Buffer Propriedade

Definição

Obtém o buffer de dados recebidos em uma mensagem de resposta de eco do protocolo 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()

Valor da propriedade

Byte[]

Uma matriz Byte que contém os dados recebidos em uma mensagem de resposta de eco ICMP ou uma matriz vazia se nenhuma resposta foi recebida.

Exemplos

O exemplo de código a seguir envia uma solicitação de eco ICMP de forma síncrona e exibe o tamanho do buffer retornado por essa propriedade.

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

Comentários

O buffer de dados enviado com a solicitação de eco ICMP é retornado ao remetente na resposta de eco para que o tempo de viagem de ida e volta para um pacote de um tamanho conhecido possa ser calculado. O buffer de dados, combinado com a opção DontFragment , pode ser usado para descobrir a unidade de transmissão máxima para o caminho de rede entre os computadores de origem e de destino. Para obter informações adicionais, consulte "Traceroute" no RFC 1574, Seção 3.2, disponível em https://www.ietf.org.

O buffer padrão usado com Send e SendAsync contém 32 bytes de dados.

Aplica-se a