public class UtilIpChecker extends Object
Constructor and Description |
---|
UtilIpChecker() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isAvailable(String host,
int port)
Check if a service is available through socket layer
|
static boolean |
isReachable(String ip,
int timeout)
Check if an IP is reachable.
|
static boolean |
isReachable(String ip,
int port,
int timeout)
Connect using layer4 (sockets).
|
public static boolean isReachable(String ip, int timeout)
Watch out this method is ICMP based. It may not work if you have firewalls. Check the variant using a host port on an expected remote TCP server.
ip
- the host name or dotted ip address to check fortimeout
- the timeout in millisecondspublic static boolean isReachable(String ip, int port, int timeout)
If the connection is successful, it is closed. That means the remote server will experience an empty connection, make sure that is ok.
ip
- the host name or dotted ip address to check forport
- the destination porttimeout
- the timeout in millisecondspublic static boolean isAvailable(String host, int port)
host
- host name or addressport
- port numberCopyright © 2014–2022. All rights reserved.