PingReply.Address 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得主機位址,該主機傳送網際網路控制訊息通訊協定 (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
屬性值
IPAddress,包含 ICMP 回應訊息的目的端。
範例
下列程式代碼範例會同步傳送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 位址。