PingReply.Address プロパティ

定義

ICMP (インターネット制御メッセージ プロトコル) エコー応答を送信するホストのアドレスを取得します。

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

プロパティ値

ICMP エコー メッセージの送信先を格納している IPAddress

次のコード例では、ICMP エコー要求を同期的に送信し、このプロパティの値を表示します。

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

注釈

Addressいずれかのオーバーロードによって返される はSend、悪意のあるリモート コンピューターから発生する可能性があります。 このアドレスを使用してリモート コンピューターに接続しないでください。 DNS を使用して、接続先のマシンの IP アドレスを確認します。

適用対象