PingReply PingReply PingReply PingReply Class

Definición

Proporciona información sobre el estado y los datos resultantes de una operación Send o SendAsync.Provides information about the status and data resulting from a Send or SendAsync operation.

public ref class PingReply
public class PingReply
type PingReply = class
Public Class PingReply
Herencia
PingReplyPingReplyPingReplyPingReply

Ejemplos

En el ejemplo de código siguiente se muestra cómo utilizar Ping clase para enviar una solicitud de eco ICMP de forma sincrónica y mostrar la respuesta.The following code example demonstrates using Ping class to send an ICMP echo request synchronously and display the response.

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::Net::NetworkInformation;
using namespace System::Text;

// args[1] can be an IPaddress or host name.
int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();
   
   Ping ^ pingSender = gcnew Ping;
   PingOptions ^ options = gcnew PingOptions;
   
   // Use the default Ttl value which is 128,
   // but change the fragmentation behavior.
   options->DontFragment = true;
   
   // Create a buffer of 32 bytes of data to be transmitted.
   String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
   array<Byte>^buffer = Encoding::ASCII->GetBytes( data );
   int timeout = 120;
   PingReply ^ reply = pingSender->Send( args[ 1 ], 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 );
   }

   
}

using System;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;

namespace Examples.System.Net.NetworkInformation.PingTest
{
    public class PingExample
    {
        // args[0] can be an IPaddress or host name.
        public static void Main (string[] args)
        {
            Ping pingSender = new Ping ();
            PingOptions options = new PingOptions ();

            // Use the default Ttl value which is 128,
            // but change the fragmentation behavior.
            options.DontFragment = true;

            // Create a buffer of 32 bytes of data to be transmitted.
            string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
            byte[] buffer = Encoding.ASCII.GetBytes (data);
            int timeout = 120;
            PingReply reply = pingSender.Send (args[0], 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);
            }
        }
    }
}

Comentarios

La Ping clase intenta enviar una solicitud de eco del protocolo de mensajes de Control de Internet (ICMP) a un equipo remoto y recibir información desde el equipo a través de un mensaje de respuesta de eco ICMP.The Ping class attempts to send an Internet Control Message Protocol (ICMP) echo request to a remote computer and receive information back from the computer via an ICMP echo reply message. El Ping clase utiliza instancias de la PingReply clase para devolver información sobre la operación, como su estado y el tiempo dedicado a enviar la solicitud y recibir la respuesta.The Ping class uses instances of the PingReply class to return information about the operation, such as its status and the time taken to send the request and receive the reply.

El Send métodos devuelven instancias de la PingReply directamente la clase.The Send methods return instances of the PingReply class directly. El SendAsync métodos devuelven un PingReply en el PingCompletedEventHandler del método PingCompletedEventArgs parámetro.The SendAsync methods return a PingReply in the PingCompletedEventHandler method's PingCompletedEventArgs parameter. El PingReply se accede a través del Reply propiedad.The PingReply is accessed through the Reply property.

Si el valor de Status no Success, no debe usar los valores devueltos por la RoundtripTime, Options o Buffer propiedades.If the value of Status is not Success, you should not use the values returned by the RoundtripTime, Options or Buffer properties. El RoundtripTime propiedad devolverá cero, el Buffer propiedad devolverá una matriz vacía y el Options propiedad devolverá null.The RoundtripTime property will return zero, the Buffer property will return an empty array, and the Options property will return null.

Propiedades

Address Address Address Address

Obtiene la dirección del host que envía el mensaje de respuesta de eco ICPM (Protocolo de mensajes de control de Internet).Gets the address of the host that sends the Internet Control Message Protocol (ICMP) echo reply.

Buffer Buffer Buffer Buffer

Obtiene el búfer de datos recibidos en un mensaje de respuesta de eco ICMP (Protocolo de mensajes de control de Internet).Gets the buffer of data received in an Internet Control Message Protocol (ICMP) echo reply message.

Options Options Options Options

Obtiene las opciones utilizadas para transmitir la respuesta a un mensaje de solicitud de eco ICPM (Protocolo de mensajes de control de Internet).Gets the options used to transmit the reply to an Internet Control Message Protocol (ICMP) echo request.

RoundtripTime RoundtripTime RoundtripTime RoundtripTime

Obtiene el número de milisegundos empleados en enviar un mensaje de solicitud de eco ICMP (Protocolo de mensajes de control de Internet) y recibir el mensaje de respuesta de eco ICMP correspondiente.Gets the number of milliseconds taken to send an Internet Control Message Protocol (ICMP) echo request and receive the corresponding ICMP echo reply message.

Status Status Status Status

Obtiene el estado de un intento de envío de un mensaje de solicitud de eco ICMP (Protocolo de mensajes de control de Internet) y la recepción del mensaje de respuesta de eco ICMP correspondiente.Gets the status of an attempt to send an Internet Control Message Protocol (ICMP) echo request and receive the corresponding ICMP echo reply message.

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Se aplica a