PingReply PingReply PingReply PingReply Class

Definition

Stellt Informationen über den Status und die Daten bereit, die aus einem Send-Vorgang oder einem SendAsync-Vorgang resultieren. 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
Vererbung
PingReplyPingReplyPingReplyPingReply

Beispiele

Das folgende Codebeispiel veranschaulicht die Verwendung Ping Klasse, um eine ICMP-Echoanfrage synchron gesendet und der Antwort angezeigt.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);
            }
        }
    }
}

Hinweise

Die Ping Klasse versucht, eine Internet Control Message Protocol (ICMP)-Echoanfrage zu einem Remotecomputer zu senden und Empfangen von Informationen aus den Computer über ein ICMP-echoantwortmeldung.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. Die Ping Klasse verwendet Instanzen der PingReply Klasse die Rückgabe von Informationen über den Vorgang, z. B. seinen Status und die Zeitdauer für die Anforderung senden und Empfangen der Antwort.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.

Die Send Methoden geben Instanzen zurück. die PingReply -Klasse direkt.The Send methods return instances of the PingReply class directly. Die SendAsync Methoden zurückgeben einer PingReply in die PingCompletedEventHandler Methode PingCompletedEventArgs Parameter.The SendAsync methods return a PingReply in the PingCompletedEventHandler method's PingCompletedEventArgs parameter. Die PingReply erfolgt über die Reply Eigenschaft.The PingReply is accessed through the Reply property.

Wenn der Wert des Status ist nicht Success, Sie sollten nicht verwenden, die Rückgabewerte der RoundtripTime, Options oder Buffer Eigenschaften.If the value of Status is not Success, you should not use the values returned by the RoundtripTime, Options or Buffer properties. Die RoundtripTime Eigenschaft gibt NULL zurück, die Buffer Eigenschaft gibt ein leeres Array, und die Options -Eigenschaft zurück null.The RoundtripTime property will return zero, the Buffer property will return an empty array, and the Options property will return null.

Eigenschaften

Address Address Address Address

Ruft die Adresse des Hosts ab, der die ICMP (Internet Control Message Protocol)-Echoantwort sendet. Gets the address of the host that sends the Internet Control Message Protocol (ICMP) echo reply.

Buffer Buffer Buffer Buffer

Ruft den in einer ICMP (Internet Control Message Protocol)-Echoantwortmeldung empfangenen Datenpuffer ab. Gets the buffer of data received in an Internet Control Message Protocol (ICMP) echo reply message.

Options Options Options Options

Ruft die Optionen zum Übertragen der Antwort auf eine ICMP (Internet Control Message Protocol)-Echoanfrage ab. Gets the options used to transmit the reply to an Internet Control Message Protocol (ICMP) echo request.

RoundtripTime RoundtripTime RoundtripTime RoundtripTime

Ruft die Anzahl von Millisekunden ab, die zum Senden einer ICMP-Echoanfrage (Internet Control Message Protocol) und zum Empfangen der entsprechenden ICMP-Echoantwortmeldung benötigt wurden. 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

Ruft den Status eines Versuchs ab, eine ICMP (Internet Control Message Protocol)-Echoanfrage zu senden und die entsprechende ICMP-Echoantwortmeldung zu empfangen. Gets the status of an attempt to send an Internet Control Message Protocol (ICMP) echo request and receive the corresponding ICMP echo reply message.

Methoden

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

Bestimmt, ob das angegebene Objekt mit dem aktuellen Objekt identisch ist. Determines whether the specified object is equal to the current object.

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

Fungiert als die Standardhashfunktion. Serves as the default hash function.

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

Ruft den Type der aktuellen Instanz ab. Gets the Type of the current instance.

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

Erstellt eine flache Kopie des aktuellen Object. Creates a shallow copy of the current Object.

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

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt. Returns a string that represents the current object.

(Inherited from Object)

Gilt für: