Condividi tramite


InetAddress.IsReachable Method

Definition

Overloads

IsReachable(Int32)

Test whether that address is reachable.

IsReachable(NetworkInterface, Int32, Int32)

Test whether that address is reachable.

IsReachable(Int32)

Test whether that address is reachable.

[Android.Runtime.Register("isReachable", "(I)Z", "GetIsReachable_IHandler")]
public virtual bool IsReachable (int timeout);
[<Android.Runtime.Register("isReachable", "(I)Z", "GetIsReachable_IHandler")>]
abstract member IsReachable : int -> bool
override this.IsReachable : int -> bool

Parameters

timeout
Int32

the time, in milliseconds, before the call aborts

Returns

a boolean indicating if the address is reachable.

Attributes

Exceptions

if an error occurs during an I/O operation.

if timeout is less than zero.

Remarks

Test whether that address is reachable. Best effort is made by the implementation to try to reach the host, but firewalls and server configuration may block requests resulting in a unreachable status while some specific ports may be accessible.

Android implementation attempts ICMP ECHO REQUESTs first, on failure it will fall back to TCP ECHO REQUESTs. Success on either protocol will return true.

The timeout value, in milliseconds, indicates the maximum amount of time the try should take. If the operation times out before getting an answer, the host is deemed unreachable. A negative value will result in an IllegalArgumentException being thrown.

Added in 1.5.

Java documentation for java.net.InetAddress.isReachable(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

IsReachable(NetworkInterface, Int32, Int32)

Test whether that address is reachable.

[Android.Runtime.Register("isReachable", "(Ljava/net/NetworkInterface;II)Z", "GetIsReachable_Ljava_net_NetworkInterface_IIHandler")]
public virtual bool IsReachable (Java.Net.NetworkInterface? netif, int ttl, int timeout);
[<Android.Runtime.Register("isReachable", "(Ljava/net/NetworkInterface;II)Z", "GetIsReachable_Ljava_net_NetworkInterface_IIHandler")>]
abstract member IsReachable : Java.Net.NetworkInterface * int * int -> bool
override this.IsReachable : Java.Net.NetworkInterface * int * int -> bool

Parameters

netif
NetworkInterface

the NetworkInterface through which the test will be done, or null for any interface

ttl
Int32

the maximum numbers of hops to try or 0 for the default

timeout
Int32

the time, in milliseconds, before the call aborts

Returns

a booleanindicating if the address is reachable.

Attributes

Exceptions

if an error occurs during an I/O operation.

if ttl or timeout is less than zero.

Remarks

Test whether that address is reachable. Best effort is made by the implementation to try to reach the host, but firewalls and server configuration may block requests resulting in a unreachable status while some specific ports may be accessible.

Android implementation attempts ICMP ECHO REQUESTs first, on failure it will fall back to TCP ECHO REQUESTs. Success on either protocol will return true.

The network interface and ttl parameters let the caller specify which network interface the test will go through and the maximum number of hops the packets should go through. A negative value for the ttl will result in an IllegalArgumentException being thrown.

The timeout value, in milliseconds, indicates the maximum amount of time the try should take. If the operation times out before getting an answer, the host is deemed unreachable. A negative value will result in an IllegalArgumentException being thrown.

Added in 1.5.

Java documentation for java.net.InetAddress.isReachable(java.net.NetworkInterface, int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to