java - getByName() - how to elaborate on cause? -
with inetaddress.getbyname() able distinguish between
- the name service replied, , result negative
and
- the name service did not reply (no connectivity dns server or whatever)
i believe there's huge difference between 2 in terms of support, i.e. telling problem. it's difference between problem argument vs infrastructure problem.
so how can distinguish between two?
as see there's unknownhostexception in both cases , message text similar. ideas ?
code snippet clarify:
try { inetaddress addr = inetaddress.getbyname(hostname); } catch (unknownhostexception ex) { if ( ..... ) { system.out.println("name server replied did not know \"" + hostname + "\""); } else { system.out.println("name server not contacted"); } }
to specific: .....
in example ??
as extension, code try/catch function ping ip address given see response (as defined in (java code ping ip address) posting).
by doing so, use function , verify why problem occurred. might recommend testing in advance if possible (e.g. before try connect directly).
Comments
Post a Comment