Network.Ping 方法

定義

ping指定的伺服器。

多載

名稱 Description
Ping(Uri, Int32)

ping指定的伺服器。

Ping(String, Int32)

ping指定的伺服器。

Ping(String)

ping指定的伺服器。

Ping(Uri)

ping指定的伺服器。

Ping(Uri, Int32)

ping指定的伺服器。

public:
 bool Ping(Uri ^ address, int timeout);
public bool Ping(Uri address, int timeout);
member this.Ping : Uri * int -> bool
Public Function Ping (address As Uri, timeout As Integer) As Boolean

參數

address
Uri

伺服器的 URI 來 ping 。

timeout
Int32

聯絡目的地的時間閾值以毫秒為單位。 預設值為 500。

傳回

True 若手術成功;否則 False

例外狀況

目前沒有網路連線可用。

網址無效。

範例

此範例透過判斷方法是否 Ping 回傳 True來報告伺服器是否能被 ping 到。

If My.Computer.Network.Ping("198.01.01.01") Then
   MsgBox("Server pinged successfully.")
Else
   MsgBox("Ping request timed out.")
End If

用伺服器的 IP 位址、URL 或電腦名稱來 "198.01.01.01" ping 通。

此範例透過判斷方法是否 Ping 回傳 True 來回報伺服器是否能被 ping ,並指定 1000 毫秒的逾時間隔。

If My.Computer.Network.Ping("www.cohowinery.com",1000) Then
   MsgBox("Server pinged successfully.")
Else
   MsgBox("Ping request timed out.")
End If

用伺服器的 IP 位址、URL 或電腦名稱來 "www.cohowinery.com" ping 通。

備註

Ping 方法並非判斷遠端電腦可用性的萬無一失的方法:目標電腦的 ping 埠可能會被關閉,或被防火牆或路由器阻擋 ping 請求。

傳遞給方法 Ping 的位址必須是 DNS 可解析的,且不能在前加上「http://」。

另請參閱

適用於

Ping(String, Int32)

ping指定的伺服器。

public:
 bool Ping(System::String ^ hostNameOrAddress, int timeout);
public bool Ping(string hostNameOrAddress, int timeout);
member this.Ping : string * int -> bool
Public Function Ping (hostNameOrAddress As String, timeout As Integer) As Boolean

參數

hostNameOrAddress
String

伺服器的 URL、電腦名稱或 IP 號碼來 ping 。

timeout
Int32

聯絡目的地的時間閾值以毫秒為單位。 預設值為 500。

傳回

True 若手術成功;否則 False

例外狀況

目前沒有網路連線可用。

網址無效。

範例

此範例透過判斷方法是否 Ping 回傳 True來報告伺服器是否能被 ping 到。

If My.Computer.Network.Ping("198.01.01.01") Then
   MsgBox("Server pinged successfully.")
Else
   MsgBox("Ping request timed out.")
End If

用伺服器的 IP 位址、URL 或電腦名稱來 "198.01.01.01" ping 通。

此範例透過判斷方法是否 Ping 回傳 True 來回報伺服器是否能被 ping ,並指定 1000 毫秒的逾時間隔。

If My.Computer.Network.Ping("www.cohowinery.com",1000) Then
   MsgBox("Server pinged successfully.")
Else
   MsgBox("Ping request timed out.")
End If

用伺服器的 IP 位址、URL 或電腦名稱來 "www.cohowinery.com" ping 通。

備註

Ping 方法並非判斷遠端電腦可用性的萬無一失的方法:目標電腦的 ping 埠可能會被關閉,或被防火牆或路由器阻擋 ping 請求。

傳遞給方法 Ping 的位址必須是 DNS 可解析的,且不能在前加上「http://」。

另請參閱

適用於

Ping(String)

ping指定的伺服器。

public:
 bool Ping(System::String ^ hostNameOrAddress);
public bool Ping(string hostNameOrAddress);
member this.Ping : string -> bool
Public Function Ping (hostNameOrAddress As String) As Boolean

參數

hostNameOrAddress
String

伺服器的 URL、電腦名稱或 IP 號碼來 ping 。

傳回

True 若手術成功;否則 False

例外狀況

目前沒有網路連線可用。

網址無效。

範例

此範例透過判斷方法是否 Ping 回傳 True來報告伺服器是否能被 ping 到。

If My.Computer.Network.Ping("198.01.01.01") Then
   MsgBox("Server pinged successfully.")
Else
   MsgBox("Ping request timed out.")
End If

用伺服器的 IP 位址、URL 或電腦名稱來 "198.01.01.01" ping 通。

此範例透過判斷方法是否 Ping 回傳 True 來回報伺服器是否能被 ping ,並指定 1000 毫秒的逾時間隔。

If My.Computer.Network.Ping("www.cohowinery.com",1000) Then
   MsgBox("Server pinged successfully.")
Else
   MsgBox("Ping request timed out.")
End If

用伺服器的 IP 位址、URL 或電腦名稱來 "www.cohowinery.com" ping 通。

備註

Ping 方法並非判斷遠端電腦可用性的萬無一失的方法:目標電腦的 ping 埠可能會被關閉,或被防火牆或路由器阻擋 ping 請求。

傳遞給方法 Ping 的位址必須是 DNS 可解析的,且不能在前加上「http://」。

另請參閱

適用於

Ping(Uri)

ping指定的伺服器。

public:
 bool Ping(Uri ^ address);
public bool Ping(Uri address);
member this.Ping : Uri -> bool
Public Function Ping (address As Uri) As Boolean

參數

address
Uri

伺服器的 URI 來 ping 。

傳回

True 若手術成功;否則 False

例外狀況

目前沒有網路連線可用。

網址無效。

範例

此範例透過判斷方法是否 Ping 回傳 True來報告伺服器是否能被 ping 到。

If My.Computer.Network.Ping("198.01.01.01") Then
   MsgBox("Server pinged successfully.")
Else
   MsgBox("Ping request timed out.")
End If

用伺服器的 IP 位址、URL 或電腦名稱來 "198.01.01.01" ping 通。

此範例透過判斷方法是否 Ping 回傳 True 來回報伺服器是否能被 ping ,並指定 1000 毫秒的逾時間隔。

If My.Computer.Network.Ping("www.cohowinery.com",1000) Then
   MsgBox("Server pinged successfully.")
Else
   MsgBox("Ping request timed out.")
End If

用伺服器的 IP 位址、URL 或電腦名稱來 "www.cohowinery.com" ping 通。

備註

Ping 方法並非判斷遠端電腦可用性的萬無一失的方法:目標電腦的 ping 埠可能會被關閉,或被防火牆或路由器阻擋 ping 請求。

傳遞給方法 Ping 的位址必須是 DNS 可解析的,且不能在前加上「http://」。

另請參閱

適用於