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. Check internet exists using win32

Check internet exists using win32

Scheduled Pinned Locked Moved C / C++ / MFC
6 Posts 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi all. I need a function to check whether internet connection exists on a local machine. There is a Wininet api for it but apparently, it is not full proof. There are cases it does not give correct answer. If I use a function to connect to certain url to check whether internet exists, it is also very slow and often freeze the hosting apps. Anyone know how to detect internet connection with a good response (QUICK)? or anyone has implemented a code for it already and willing to share?

    M 1 Reply Last reply
    0
    • L Lost User

      Hi all. I need a function to check whether internet connection exists on a local machine. There is a Wininet api for it but apparently, it is not full proof. There are cases it does not give correct answer. If I use a function to connect to certain url to check whether internet exists, it is also very slow and often freeze the hosting apps. Anyone know how to detect internet connection with a good response (QUICK)? or anyone has implemented a code for it already and willing to share?

      M Offline
      M Offline
      Masaaki Onishi
      wrote on last edited by
      #2

      Hello, the codegurus around the world.;) First of all, I can't share this code since this code is my company property. One way is to use NON-BLOCKING socket. 1) Get the source code the raw socket of ping code from MSDN sample. 2) Use the NON-BLOCKING socket (this prevents the program from hanging.) 3) Find DNS of LAN and ping to the couple of URL. Acutually, WinInet class isn't as powerful tool as we think. I guess that this uses BLOCKING socket, so we have to write our own class...:(( We may also use thread with BLOKCING socket (WinInet). So,this may prevent the application hanging. Also, the response speed is an issue. As long as we use LAN, DNS detection is enough, and fast. But, without LAN, and ISP connection, we only use something like URL. Anyway, good luck. :rolleyes: Have a nice day! -Masaaki Onishi-

      H 1 Reply Last reply
      0
      • M Masaaki Onishi

        Hello, the codegurus around the world.;) First of all, I can't share this code since this code is my company property. One way is to use NON-BLOCKING socket. 1) Get the source code the raw socket of ping code from MSDN sample. 2) Use the NON-BLOCKING socket (this prevents the program from hanging.) 3) Find DNS of LAN and ping to the couple of URL. Acutually, WinInet class isn't as powerful tool as we think. I guess that this uses BLOCKING socket, so we have to write our own class...:(( We may also use thread with BLOKCING socket (WinInet). So,this may prevent the application hanging. Also, the response speed is an issue. As long as we use LAN, DNS detection is enough, and fast. But, without LAN, and ISP connection, we only use something like URL. Anyway, good luck. :rolleyes: Have a nice day! -Masaaki Onishi-

        H Offline
        H Offline
        Hendrik Kurniawan
        wrote on last edited by
        #3

        Hi. Thanks for the answer. However, using ping is not very good idea because a site might block the request. Hence, there is always a request time out. Any other method that I could use? Thanks Hendrik

        M 1 Reply Last reply
        0
        • H Hendrik Kurniawan

          Hi. Thanks for the answer. However, using ping is not very good idea because a site might block the request. Hence, there is always a request time out. Any other method that I could use? Thanks Hendrik

          M Offline
          M Offline
          Masaaki Onishi
          wrote on last edited by
          #4

          Hello, the codegurus around the world. So, I told that the application pings to a couple of URL. In fact, www.cnn.com didn't work for the ping. CNN web site adds some functionality to take off ping command from the router? If at least of one URL among 100 URLs works, this measn the local computer connects Internet.:eek: We don't need all 100 URL information, so if 5th URL works,just skip 95 URLs. Good Luck :rose: Have a nice day! -Masaaki Onishi-

          K 1 Reply Last reply
          0
          • M Masaaki Onishi

            Hello, the codegurus around the world. So, I told that the application pings to a couple of URL. In fact, www.cnn.com didn't work for the ping. CNN web site adds some functionality to take off ping command from the router? If at least of one URL among 100 URLs works, this measn the local computer connects Internet.:eek: We don't need all 100 URL information, so if 5th URL works,just skip 95 URLs. Good Luck :rose: Have a nice day! -Masaaki Onishi-

            K Offline
            K Offline
            Kannan Kalyanaraman
            wrote on last edited by
            #5

            why not ping codeproject.com ;P

            M 1 Reply Last reply
            0
            • K Kannan Kalyanaraman

              why not ping codeproject.com ;P

              M Offline
              M Offline
              Masaaki Onishi
              wrote on last edited by
              #6

              Hello, the codegurus around the world.;) Basically, I don't want to make Codeproject website slow....:(( We should avoid DOS (Denial Of Service) ? to Codeproject web site. Even though Codeguru web site responses fast, Codeproject responses too slow. I hope that Codeproject web site uses mutli-cast host for this web site.:rolleyes: Have a nice day! -Masaaki Onishi-

              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