Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Determine whether connected to internet

Determine whether connected to internet

Scheduled Pinned Locked Moved C / C++ / MFC
comtestingbeta-testingquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jase Jennings
    wrote on last edited by
    #1

    I'm a little confused regarding InternetGetConnectedState(). If I run this function without a connection, dwFlags returns RAS, LAN and CONFIGURED If I run this function with a connection, dwFlags returns RAS, MODEM and CONFIGURED ... so in truth, it doesn't appear that InternetGetConnectedState() is a very reliable test of whether or not you have an open connection. It seems to think that just because I have a LAN, that i must also be connected to the internet. Perhaps, it is merely testing for active ip traffic, sees the LAN, and hopes that it may be an internet source. I think this function simply returns true if it sees that you have a connectoid configured, regardless of whether you are connected My only concern is that if it returns true, i assume a connection and then use other inernet sdk functions. If in fact there is not a connection, then a dialup is thrown. I don't want to throw up a dialup without first asking the user if they are ok for me to throw a dialup. Sure, i can inform them that running the functionality requires an internet connection and then they'll not be too surprised to see the dialup if i throw one. But as a developer, i'm obviously looking for the perfect solution. I've also tried InternetAttemptConnect(0), and it always tell me that i am connected I've also tried InternetCheckConnection(), and it always tells me that i am not connected Whats a developer to do ? Is there any method that i can rely on ? Jase ------------------------------------------------------------------------------------------------------------------------------------------------------------------- View your digital photos and images with ease using the ultimate desktop image manager for Microsoft Windows Download your free copy of SlideShow Desktop today from http://www.slideshowdesktop.com

    L N 2 Replies Last reply
    0
    • J Jase Jennings

      I'm a little confused regarding InternetGetConnectedState(). If I run this function without a connection, dwFlags returns RAS, LAN and CONFIGURED If I run this function with a connection, dwFlags returns RAS, MODEM and CONFIGURED ... so in truth, it doesn't appear that InternetGetConnectedState() is a very reliable test of whether or not you have an open connection. It seems to think that just because I have a LAN, that i must also be connected to the internet. Perhaps, it is merely testing for active ip traffic, sees the LAN, and hopes that it may be an internet source. I think this function simply returns true if it sees that you have a connectoid configured, regardless of whether you are connected My only concern is that if it returns true, i assume a connection and then use other inernet sdk functions. If in fact there is not a connection, then a dialup is thrown. I don't want to throw up a dialup without first asking the user if they are ok for me to throw a dialup. Sure, i can inform them that running the functionality requires an internet connection and then they'll not be too surprised to see the dialup if i throw one. But as a developer, i'm obviously looking for the perfect solution. I've also tried InternetAttemptConnect(0), and it always tell me that i am connected I've also tried InternetCheckConnection(), and it always tells me that i am not connected Whats a developer to do ? Is there any method that i can rely on ? Jase ------------------------------------------------------------------------------------------------------------------------------------------------------------------- View your digital photos and images with ease using the ultimate desktop image manager for Microsoft Windows Download your free copy of SlideShow Desktop today from http://www.slideshowdesktop.com

      L Offline
      L Offline
      l a u r e n
      wrote on last edited by
      #2

      you don't want to try pinging a known ip address outside of your local network and seeing if you get a response? --- "every year we invent better idiot proof systems and every year they invent better idiots ... and the linux zealots still aren't being sterilized"

      J 1 Reply Last reply
      0
      • J Jase Jennings

        I'm a little confused regarding InternetGetConnectedState(). If I run this function without a connection, dwFlags returns RAS, LAN and CONFIGURED If I run this function with a connection, dwFlags returns RAS, MODEM and CONFIGURED ... so in truth, it doesn't appear that InternetGetConnectedState() is a very reliable test of whether or not you have an open connection. It seems to think that just because I have a LAN, that i must also be connected to the internet. Perhaps, it is merely testing for active ip traffic, sees the LAN, and hopes that it may be an internet source. I think this function simply returns true if it sees that you have a connectoid configured, regardless of whether you are connected My only concern is that if it returns true, i assume a connection and then use other inernet sdk functions. If in fact there is not a connection, then a dialup is thrown. I don't want to throw up a dialup without first asking the user if they are ok for me to throw a dialup. Sure, i can inform them that running the functionality requires an internet connection and then they'll not be too surprised to see the dialup if i throw one. But as a developer, i'm obviously looking for the perfect solution. I've also tried InternetAttemptConnect(0), and it always tell me that i am connected I've also tried InternetCheckConnection(), and it always tells me that i am not connected Whats a developer to do ? Is there any method that i can rely on ? Jase ------------------------------------------------------------------------------------------------------------------------------------------------------------------- View your digital photos and images with ease using the ultimate desktop image manager for Microsoft Windows Download your free copy of SlideShow Desktop today from http://www.slideshowdesktop.com

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #3

        Try using InetIsOffline Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

        J 1 Reply Last reply
        0
        • L l a u r e n

          you don't want to try pinging a known ip address outside of your local network and seeing if you get a response? --- "every year we invent better idiot proof systems and every year they invent better idiots ... and the linux zealots still aren't being sterilized"

          J Offline
          J Offline
          Jase Jennings
          wrote on last edited by
          #4

          not really ... if your not connected it can take too long to timeout Jase ------------------------------------------------------------------------------------------------------------------------------------------------------------------- View your digital photos and images with ease using the ultimate desktop image manager for Microsoft Windows Download your free copy of SlideShow Desktop today from http://www.slideshowdesktop.com

          1 Reply Last reply
          0
          • N Nish Nishant

            Try using InetIsOffline Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

            J Offline
            J Offline
            Jase Jennings
            wrote on last edited by
            #5

            But InetIsOffline() doesn't check for an internet connection. It merely checks to see if you have selected "Work Offline" in IE or Outlook. <-- Snippet from MSDN --> "Returns TRUE if the local system in not currently connected to the Internet. Returns FALSE if the local system is connected to the Internet or if no attempt has yet been made to connect to the Internet" <-- Snippet End --> By default, Windows assumes that you are connected to the internet as soon as you log on to Windows. The result of this is that InetIsOffline() will inform you that you are connected to the internet even if you are not, simply because you are not in 'Work Offline' mode ... I'm beginning to doubt that the holy grail exists and am forming the opinion that there are no sdk or api functions that can reliably tell ou whether or not you are connected to the internet, and - this is the most important bit - not throw a dialup box if you are not connected. ? Jase ------------------------------------------------------------------------------------------------------------------------------------------------------------------- View your digital photos and images with ease using the ultimate desktop image manager for Microsoft Windows Download your free copy of SlideShow Desktop today from http://www.slideshowdesktop.com

            N 1 Reply Last reply
            0
            • J Jase Jennings

              But InetIsOffline() doesn't check for an internet connection. It merely checks to see if you have selected "Work Offline" in IE or Outlook. <-- Snippet from MSDN --> "Returns TRUE if the local system in not currently connected to the Internet. Returns FALSE if the local system is connected to the Internet or if no attempt has yet been made to connect to the Internet" <-- Snippet End --> By default, Windows assumes that you are connected to the internet as soon as you log on to Windows. The result of this is that InetIsOffline() will inform you that you are connected to the internet even if you are not, simply because you are not in 'Work Offline' mode ... I'm beginning to doubt that the holy grail exists and am forming the opinion that there are no sdk or api functions that can reliably tell ou whether or not you are connected to the internet, and - this is the most important bit - not throw a dialup box if you are not connected. ? Jase ------------------------------------------------------------------------------------------------------------------------------------------------------------------- View your digital photos and images with ease using the ultimate desktop image manager for Microsoft Windows Download your free copy of SlideShow Desktop today from http://www.slideshowdesktop.com

              N Offline
              N Offline
              Nish Nishant
              wrote on last edited by
              #6

              oh, sorry! Then your only option is to try and connect to some site. Say try connecting to yahoo.com port 80 and if you can connect, you are online, else you are not. Of course there is a danger that yahoo is down. so try two other sites too just to be safe. Try say, microsoft.com and then try google.com Nish p.s. sorry if this is a really stupid idea, but I see no other way. Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups