PingReply.RoundtripTime PingReply.RoundtripTime PingReply.RoundtripTime PingReply.RoundtripTime Property

Definition

Ruft die Anzahl von Millisekunden ab, die zum Senden einer ICMP (Internet Control Message Protocol)- Echoanfrage 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.

public:
 property long RoundtripTime { long get(); };
public long RoundtripTime { get; }
member this.RoundtripTime : int64
Public ReadOnly Property RoundtripTime As Long

Eigenschaftswert

Ein Int64, das die Roundtripzeit in Millisekunden angibt.An Int64 that specifies the round trip time, in milliseconds.

Beispiele

Im folgenden Codebeispiel wird eine ICMP-Echo Anforderung synchron gesendet und die Größe des von dieser Eigenschaft zurückgegebenen Puffers angezeigt.The following code example sends an ICMP echo request synchronously and displays the size of the buffer returned by this property.

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

Hinweise

Wenn die Echo Anforderung fehlschlägt, RoundtripTime wird die Uhrzeit als 0 (null) gemeldet. Dies ist auch ein gültiger Wert, wenn die Anforderung erfolgreich ausgeführt wird.If the Echo request fails, the RoundtripTime time is reported as 0, which is also a valid value when the request succeeds. Sie müssen das Status überprüfen, um zu bestimmen, ob der von dieser Eigenschaft zurückgegebene Wert ignoriert werden soll.You must check the Status to determine whether the value returned by this property should be ignored.

Gilt für: