You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ralph Einfeldt <ra...@uptime-isc.de> on 2003/05/21 09:53:10 UTC

RE: checking if the macjhine is connected to the network from within tomcat.

If you pull the cable the dns lookup fails.
The problem is, that the java libraries cache failed lookups per default.
In 1.4.1 the cache latency is 10 seconds. I don't know what it is for 
other versions
You have to disable the lookup caching (AFAIK only possible in JDK >= 1.4):

http://java.sun.com/j2se/1.4.1/docs/api/java/net/InetAddress.html

Otherwise you can try to use the IP.

> -----Original Message-----
> From: Manu Kumar [mailto:ManuK@digitalthink.com]
> Sent: Wednesday, May 21, 2003 12:43 AM
> To: 'Tomcat Users List'
> Subject: checking if the macjhine is connected to the network from
> within tomcat.
> 
> 
> Hello All , 
> 
> I have a webapp which needs to determine if the machine its 
> running on is
> connected to the net or not.
> [we have a desktop application which uses tomcat in embedded 
> mode to deliver
> some html content and do various other stuff ].
> 
> currently i am using URL class to create a URL instance to 
> point to say
> www.google.com , try to open the InputStream and if i get 
> some ecxception , 
> return result as not connected.
> 
> the situations which i test are : 
> 
> online --> go offline [yank the cable off :-) ] --> go 
> online. this works
> fine.
> offline --> online --> offline . this always keeps returning 
> as offline.
> 
> if i run the same code outside of tomcat , it works fine in 
> both cases.
> 
> 
> any help would be greatly appreciated .. 
> 
> does anyone have a better way to detect net connectivity 
> [without doing
> native calls] ?
> 
> 
> thanks,
> 
> manu
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org