Wednesday, July 1, 2009

Slow DNS lookup

I traced the slowness in the Monitor applet down to the DNS lookup performed by currAddr.getHostName(), where currAddr is an InetAddress object. This looks up the domain name if the address was not created with it already, in which case it just remembers it. So if I cycle through the ip-addresses on a C-class subnet and I find one that is reachable after 5 milliseconds, I need to do a reverse DNS lookup to get the domain name. But if it doesn't have one it takes 15 seconds before it times out. Strangely, it then changes the ip-address to instead of the / it started with. (Don't know what the initial "/" is for). What I want to do is specify a timeout of say 10 milliseconds for lookup to succeed within. After that I am happy to go with the numerical address. But you can't do it, apparently.

No comments:

Post a Comment