I've a small java code which test a bunch of hosts which is not reachable.
The important part is this:
for (String host : hosts) {
try {
if (!InetAddress.getByName(host).isReachable(5000)) {
System.err.println(host + " is not reachable!");
}
} catch (UnknownHostException e) {
System.err.println(host + " is unknown");
} catch (IOException e) {
System.err.println(host + "throws IOException!");
}
}
hosts
is a String[]
-Array full of URL's to test. When I run it, some URL's comes "... is not reachable!" and sometimes it comes "... is unknown".
But what is the difference between these two?
Not reachable -> No answer after 5sec to the ping
Unknown -> No host found to ping
These are only my thoughts and I can't find any confirmations or improvements in google.
Unknown host means that it couldn't resolve a DNS entry, so it doesn't know what IP address to contact.
Not reachable means that it had an IP and tried to contact it but failed (either because of a timeout or because it received a destination unreachable message).
Unknown host - Not enough information is available to contact a host / it does't know which host to contact
Unreachable - Enough information is available to contact the host but contact is not happening due to some reason (network error, timeout-host didn't respond on time, privilege issue etc.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With