Results 1 to 2 of 2

Thread: How to detect an internet connection ?

  1. #1
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    18
    Qt products
    Qt4
    Platforms
    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
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    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 22:15.

Similar Threads

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

Bookmarks

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.