PingReply.Address Właściwość

Definicja

Pobiera adres hosta, który wysyła odpowiedź echa protokołu ICMP (Internet Control Message Protocol).

public:
 property System::Net::IPAddress ^ Address { System::Net::IPAddress ^ get(); };
public System.Net.IPAddress Address { get; }
member this.Address : System.Net.IPAddress
Public ReadOnly Property Address As IPAddress

Wartość właściwości

Element IPAddress zawierający miejsce docelowe komunikatu echa ICMP.

Przykłady

Poniższy przykład kodu wysyła synchronicznie żądanie echa ICMP i wyświetla wartość tej właściwości.

void SimplePing()
{
   Ping ^ pingSender = gcnew Ping;
   PingReply ^ reply = pingSender->Send( "www.contoso.com" );
   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 SimplePing ()
{
    Ping pingSender = new Ping ();
    PingReply reply = pingSender.Send ("www.contoso.com");

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

Uwagi

Zwrócone Address przez dowolne Send przeciążenia mogą pochodzić ze złośliwego komputera zdalnego. Nie należy łączyć się z komputerem zdalnym przy użyciu tego adresu. Użyj systemu DNS, aby określić adres IP maszyny, z którą chcesz nawiązać połączenie.

Dotyczy