[Qt-interest] What's the best way to determine online status?

Constantin Makshin dinosaur-rus at users.sourceforge.net
Thu Oct 15 20:29:01 CEST 2009


I think that connecting to the server is really the best way of detecting  
the Internet connection. Simply asking the system about precense of a  
network connection and getting positive answer doesn't necessarily mean  
you're connected to the Internet (it may be a LAN connection without  
access to the "outside world"). But even using a tool that allows you to  
know there's an Internet connection, the required server may not be  
accessible for some reason.

On Thu, 15 Oct 2009 18:58:02 +0400, Murphy, Sean M.  
<sean.murphy at gd-ais.com> wrote:
> Whoops!  Forgot to put a subject!
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Murphy, Sean M.
> Sent: Thursday, October 15, 2009 10:53 AM
> To: qt-interest List
> Subject: [Qt-interest] (no subject)
>
> I'm looking for suggestions on the best way to determine if I'm
> connected to the Internet from inside my application for displaying GPS
> waypoints, like a hiking or biking path.
>
> I've got two widgets, one that I wrote back in the Qt3 days that shows
> the waypoints over a blank grey background, so the relative positions of
> the waypoints are correct, but there is no context of where it is on the
> real earth.  I've got a second widget that is based on Qt4's Webkit
> integration that shows the waypoints over Google Maps imagery.
>
> The problem is that we will regularly use this application in two
> networking environments, one where we're connected to a LAN that has no
> path to the Internet, and one where we're on a different network that
> does have connection to the Internet.  So I need to decide which widget
> to use based on my connectivity status.  I'd like to make it as seamless
> is possible to the user.
>
> The only way I've thought of at the moment is right when I launch,
> request a page from Google Maps, and set up a QNetworkReply watching for
> a error signal.  If I get an error, then I'll assume I'm on the LAN and
> use the old Qt3 widget for the remainder of that session, if I get the
> reply back successfully from Google Maps, then I'll know I'm online and
> I'll use my WebKit version.
>
> Anyone have any better ideas?
> Sean

-- 
Constantin Makshin



More information about the Qt-interest-old mailing list