Best Way to Check Network Availability
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   celtech_celtech
Posted On:   Monday, September 16, 2002 08:21 AM

I want to write java code in a thread which continually checks network availability. What is the best way to do that? Is is try to connect, sleep a few seconds and try again??: try { this.socket = new Socket(aAbinitioWS.hostServer, 1026); } catch (Exception ex) { } // sleep for 5 secs so as not to slow everything down ! try { Thread.sleep(5000); } catch (InterruptedException e) { }    More>>

I want to write java code in a thread which continually
checks network availability. What is the best way to do that?


Is is try to connect, sleep a few seconds and try again??:


try
{


this.socket = new Socket(aAbinitioWS.hostServer, 1026);


}


catch (Exception ex)


{



}



// sleep for 5 secs so as not to slow everything down !


try


{


Thread.sleep(5000);


}


catch (InterruptedException e)


{


}

   <<Less

Re: Best Way to Check Network Availability

Posted By:   Jorgen_Nordqvist  
Posted On:   Tuesday, September 17, 2002 07:52 PM

Connecting to some kind of service listening on a particular socket is one way of making sure a system/service is up and running.

Another way of checking if a system is up is to use a library like this one that allows you to ping other machines from within Java.

Jorgen

About | Sitemap | Contact