With InetAddress.getByName() I would like to be able to distinguish between
- The name service replied, and the result was negative
and
- the name service did not reply (no connectivity to DNS server or whatever)
I believe there's a huge difference between the two in terms of support, i.e. telling someone where to look for the problem. It's the difference between a problem with the argument vs an infrastructure problem.
So how can I distinguish between the two?
As I see it there's just UnknownHostException in both cases and the message text is similar. Any good ideas ?
Code snippet to clarify:
try {
InetAddress addr = InetAddress.getByName(hostname);
} catch (UnknownHostException ex) {
if ( ..... ) {
System.out.println("Name server replied but did not know \"" + hostname + "\"");
} else {
System.out.println("Name server could not be contacted");
}
}
To be specific: what would .....
be in the example ??