Add-Ons & Services

how to check for an internet connection

A general discussion forum.
Posts: 1
Joined: 04 Aug 2010, 20:35

how to check for an internet connection

Postby skankest » 04 Aug 2010, 20:46

is there a way, through poco, to check to see if there is an internet connection. I'm pulling files from the net (using URIStreamOpener) while my program initializes but if the internet is down the code gets stuck looking for the files. I've tried a try, catch loop but the lack of internet doesn't seem to throw an exeption and therefor doesn't solve the problem.

any ideas?

Posts: 163
Joined: 18 May 2009, 17:38

Re: how to check for an internet connection

Postby aderouineau » 05 Aug 2010, 01:37

Add a timeout and handle exceptions or error codes ?

You can also ping an anycast address. Why anycast ? Because it's more likely to stay in place for very long. You could resolve and ping f.root-server.net in your program for example.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests