Results 1 to 2 of 2

Thread: How to detect an internet connection ?

  1. #1
    Join Date
    Feb 2010
    Qt products
    MacOS X

    Default How to detect an internet connection ?

    Is there a simple way to detect whether a computer is connected to the internet using QT ?

    My application behaves differently whether it is in offline mode or online mode...

  2. #2
    Join Date
    Sep 2009
    Thanked 348 Times in 333 Posts
    Qt products

    Default Re: How to detect an internet connection ?

    The simplest way would be to attempt to connect a computer that is outside your LAN, such as Google. If the call succeeds, you have internet access. This may not work on some PCs at various companies, as they might only have internet access via a proxy, so they can download webpages, send/receive email, but has no internet connection otherwise.

    If your writing code for windows, then there APIs such as InternetGetConnectedState(), but even things like this are not 100% reliable. You need to actually try to connect somewhere yourself to prove 100%

    The typical way is to try to connect directly first, and if that fails, figure out the local proxy settings (if any) and try again via that route.
    Last edited by squidge; 29th March 2010 at 23:15.

Similar Threads

  1. Internet Speedometer
    By dilidpan in forum Qt Programming
    Replies: 10
    Last Post: 23rd May 2010, 16:50
  2. How to use a image from internet
    By kellen851105 in forum Qt Programming
    Replies: 1
    Last Post: 4th March 2010, 07:16
  3. Read a csv file from Internet
    By abghosh in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2010, 17:04
  4. Is internet connected
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 22:22
  5. Play chess over the Internet
    By cwnelatury in forum Qt Programming
    Replies: 1
    Last Post: 3rd June 2009, 06:12


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.