Discussion Locked

Java - detect internet connection

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

I have a Java program that uses the internet but if when there is no longer an internet connection, it ends up create a lot of errors. I was wondering if there are any methods to detect a constant internet connection using Java?

Thanks,

Carl

3 replies

by tony hopkinson

ping something external for instance. Hit ms of google with a web request, possibly both in case\one of them has gone nipples up.

You can do a bit more if you are communicating with two units you control through the internet. Establish a socket connection and do a send and wait for acknowledge every minute for instance.

Keep it simple though, the reasons why you don't have access to the internet, can be from some eejit unplugged you, to being blocked on third party firewall, even if you cover most bases, there will still be faults that you misreport.

by carlbernardi

I thought about doing it that way but I also came to the same conclusion. I was hoping that maybe the ip address assigned to the modem (dialup, adsl, cable) from the internet provider could be detected maybe via a trace route or something along those lines.

Thanks,

Carl

This discussion is closed to new replies.