This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes Check connected to internet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Check connected to internet" Watch "Check connected to internet" New topic
Author

Check connected to internet

Darrin Addams
Greenhorn

Joined: Oct 15, 2003
Posts: 1
Hi,
Can someone suggest the best way of checking if I'm connected to the internet, or a specific web server?
Is it just a case of trying to get a response from a given web server and checking it's equal to 200 so I just need to use the URLConnection class? I'm just concerned with having to wait for a response if the server is down or a route is unavailable.
Ideally, I want to write a servlet that supplies a working route to a caller.
Thanks.
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Well, there is no easy way to do this. One of the things you can do is by pinging remote servers. I suggest to create a simple class that does socket connection, and ping more than one server, since a site could be downed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Check connected to internet
 
Similar Threads
DEVELOPING AN AUTHENTICATION SYSTEM.
How to run an application as name-based in tomcat
Sending a message to a remote server
deploying web services onto the internet
update method is not getting called of observer Interface