[Qt-interest] Checking if connected to the network
David Ching
dc at dcsoft.com
Sun May 17 02:13:59 CEST 2009
> From: Thiago Macieira <thiago.macieira at trolltech.com>
> >As Thiago said, Qt doesn't have a cross platform API for this. If you
> > are interested in Windows, use the Windows API
> > InternetGetConnectedState().
> >
> That function most likely does not handle all cases. I suggest reading
> the
> MSDN documentation and finding out its limitations.
>
> Most likely, it cannot detect when you're connected to a network, but
> that
> network is not connected to the Internet.
Yes, you're right, it does not determine whether external addresses like
google.com are reachable. It's value was historically to see if the dial-up
modem had connected to the ISP, to know whether attempting to connect to an
Internet site would require the modem to dial out or not (which may not be
desirable). I think it also checks whether the network cable is attached to
the network card, and an IP address is assigned.
As the OP asked to be able to "check and see if the machine is connected to
the network," it might fit his requirements.
A cross-platform API providing this functionality would be very useful; one
common usage is to avoid a potentially long delay in trying to establish a
connection without a network cable attached, or causing a dial-up adapter to
dial. Once this API confirms basic network connectivity, testing for true
Internet connectivity would simply be connecting to a well known address
such as google.com. For convenience, a cross platform API that does this
would also be useful.
-- David
More information about the Qt-interest-old
mailing list