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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -