Test for a host being reachable using ICMP "ping" packets & echo operations. Ping packets are very reliable for assessing reachability in a LAN or WAN, but they do not get through any well-configured firewall. Echo (port 7) may.
This condition turns unknown host exceptions into false conditions. This is because on a laptop, DNS is one of the first services lost when the network goes; you are implicitly offline.
If a URL is supplied instead of a host, the hostname is extracted and used in the test--all other parts of the URL are discarded.
The test may not work through firewalls; that is, something may be reachable using a protocol such as HTTP, while the lower level ICMP packets get dropped on the floor. Similarly, a host may be detected as reachable with ICMP, but not reachable on other ports (i.e. port 80), because of firewalls.
Modifier and Type | Field and Description |
---|---|
public static final int | DEFAULT_TIMEOUT
The default timeout. |
public static final String | ERROR_BAD_TIMEOUT
Error when invalid timeout value is defined |
public static final String | ERROR_BAD_URL
Error message when an invalid url is used. |
public static final String | ERROR_BOTH_TARGETS
Error message when url and host are specified. |
public static final String | ERROR_NO_HOST_IN_URL
Error message when no hostname in url. |
public static final String | ERROR_NO_HOSTNAME
Error when no hostname is defined |
public static final String | ERROR_ON_NETWORK
Network error message is seen. |
private String | |
public static final String | METHOD_NAME
The method name to look for in InetAddress |
public static final String | MSG_NO_REACHABLE_TEST
Error message when no reachably test avail. |
private static final int | |
private int | |
private String | |
private static final String | WARN_UNKNOWN_HOST
Unknown host message is seen. |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public boolean | Returns: true if the condition is true.Implements org. |
private boolean | |
public void | |
public void | setTimeout(final int
the timeout in seconds. timeout)Set the timeout for the reachability test in seconds. |
public void |
DEFAULT_TIMEOUT | back to summary |
---|---|
public static final int DEFAULT_TIMEOUT The default timeout. |
ERROR_BAD_TIMEOUT | back to summary |
---|---|
public static final String ERROR_BAD_TIMEOUT Error when invalid timeout value is defined |
ERROR_BAD_URL | back to summary |
---|---|
public static final String ERROR_BAD_URL Error message when an invalid url is used. |
ERROR_BOTH_TARGETS | back to summary |
---|---|
public static final String ERROR_BOTH_TARGETS Error message when url and host are specified. |
ERROR_NO_HOST_IN_URL | back to summary |
---|---|
public static final String ERROR_NO_HOST_IN_URL Error message when no hostname in url. |
ERROR_NO_HOSTNAME | back to summary |
---|---|
public static final String ERROR_NO_HOSTNAME Error when no hostname is defined |
ERROR_ON_NETWORK | back to summary |
---|---|
public static final String ERROR_ON_NETWORK Network error message is seen. |
host | back to summary |
---|---|
private String host |
METHOD_NAME | back to summary |
---|---|
public static final String METHOD_NAME
Deprecated Since 1.10.6 The method name to look for in InetAddress |
MSG_NO_REACHABLE_TEST | back to summary |
---|---|
public static final String MSG_NO_REACHABLE_TEST Error message when no reachably test avail. |
SECOND | back to summary |
---|---|
private static final int SECOND |
timeout | back to summary |
---|---|
private int timeout |
url | back to summary |
---|---|
private String url |
WARN_UNKNOWN_HOST | back to summary |
---|---|
private static final String WARN_UNKNOWN_HOST Unknown host message is seen. |
IsReachable | back to summary |
---|---|
public IsReachable() |
eval | back to summary |
---|---|
public boolean eval() throws BuildException Implements org. Evaluate the condition.
|
isNullOrEmpty | back to summary |
---|---|
private boolean isNullOrEmpty(final String string) emptyness test
|
setHost | back to summary |
---|---|
public void setHost(final String host) Set the host to ping.
|
setTimeout | back to summary |
---|---|
public void setTimeout(final int timeout) Set the timeout for the reachability test in seconds.
|
setUrl | back to summary |
---|---|
public void setUrl(final String url) Set the URL from which to extract the hostname.
|