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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -