networking - How to detect network breakage using java program? -


is there way detect network breakage or weaker network, using java?

you can intermittently test http connection known host such google , detect connectionexceptions

urlconnection con = new url("http://www.google.com/").openconnection(); con.setusecaches(false); con.setallowuserinteraction(false);  while(true) {     try     {         con.connect();         con.getcontenttype(); // make sure connection works         // sleep interval     }     catch(ioexception e)     {         // handle , break     } } 

Comments

Popular posts from this blog

List<T>().Add problem C# -

Javascript natural sort array/object and maintain index association -