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. How to check internet Connectivity.

How to check internet Connectivity.

Scheduled Pinned Locked Moved C / C++ / MFC
c++jsonhelptutorial
9 Posts 5 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.
  • B Offline
    B Offline
    birajendu
    wrote on last edited by
    #1

    Hi, in my application i have a requirement to check the internet connection. The situation is my laptop is connected to LAN, and the outgoing internet trafiic is down(LAN is UP so i have the local IP). So i need to check this thru some c++ coding. I am basicaly using win32 . can you please help me out. I know the api InternetGetConnectedState(), but it always gives connected ,though i have connected to LAN. Do you have any idea how to detect that....

    Birajendu SonicWALL Bangalore India

    R D L 3 Replies Last reply
    0
    • B birajendu

      Hi, in my application i have a requirement to check the internet connection. The situation is my laptop is connected to LAN, and the outgoing internet trafiic is down(LAN is UP so i have the local IP). So i need to check this thru some c++ coding. I am basicaly using win32 . can you please help me out. I know the api InternetGetConnectedState(), but it always gives connected ,though i have connected to LAN. Do you have any idea how to detect that....

      Birajendu SonicWALL Bangalore India

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      birajendu wrote:

      I know the api InternetGetConnectedState(), but it always gives connected ,though i have connected to LAN.

      It looks like you did not read the remarks section of the API in the doc? Take a look at InternetCheckConnection()[^]. With this function, you will be able to specify a URL that the API should check connectivity to.

      It is a crappy thing, but it's life -^ Carlo Pallini

      B 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        birajendu wrote:

        I know the api InternetGetConnectedState(), but it always gives connected ,though i have connected to LAN.

        It looks like you did not read the remarks section of the API in the doc? Take a look at InternetCheckConnection()[^]. With this function, you will be able to specify a URL that the API should check connectivity to.

        It is a crappy thing, but it's life -^ Carlo Pallini

        B Offline
        B Offline
        birajendu
        wrote on last edited by
        #3

        I tried the function you said. but its always giving not connected status only...

        Birajendu SonicWALL Bangalore India

        R 1 Reply Last reply
        0
        • B birajendu

          I tried the function you said. but its always giving not connected status only...

          Birajendu SonicWALL Bangalore India

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #4

          What URL did you try with this call? Are you able to reach that URL manually from that particular machine? Do you have a firewall? Is it configured to allow this application for outbound traffic? What does GetLastError() say?

          It is a crappy thing, but it's life -^ Carlo Pallini

          B A 2 Replies Last reply
          0
          • R Rajesh R Subramanian

            What URL did you try with this call? Are you able to reach that URL manually from that particular machine? Do you have a firewall? Is it configured to allow this application for outbound traffic? What does GetLastError() say?

            It is a crappy thing, but it's life -^ Carlo Pallini

            B Offline
            B Offline
            birajendu
            wrote on last edited by
            #5

            It is giving 12006 "The URL scheme could not be recognized, or is not supported." error.I tried with giving "google.com" in url field Incase of NULL in url field it is giving 12016 "The requested operation is invalid." error. Do you have any idea how to resolve thse errors. Obviously I am able to ping google.com from my machine.

            Birajendu SonicWALL Bangalore India

            R 1 Reply Last reply
            0
            • B birajendu

              It is giving 12006 "The URL scheme could not be recognized, or is not supported." error.I tried with giving "google.com" in url field Incase of NULL in url field it is giving 12016 "The requested operation is invalid." error. Do you have any idea how to resolve thse errors. Obviously I am able to ping google.com from my machine.

              Birajendu SonicWALL Bangalore India

              R Offline
              R Offline
              Rajesh R Subramanian
              wrote on last edited by
              #6

              birajendu wrote:

              It is giving 12006 "The URL scheme could not be recognized, or is not supported." error.I tried with giving "google.com" in url field

              You tried passing "google.com" as the lpszUrl field value? The documentation has a description for this field, and that says: Pointer to a null-terminated string that specifies the URL[^] to use to check the connection. Notice that URL has a syntax. A valid URL that can be passed as lpszURL would look like: _T("http://www.google.com") Also, take a look at the example provided in MSDN for InternetGetConnectedState[^]

              It is a crappy thing, but it's life -^ Carlo Pallini

              1 Reply Last reply
              0
              • B birajendu

                Hi, in my application i have a requirement to check the internet connection. The situation is my laptop is connected to LAN, and the outgoing internet trafiic is down(LAN is UP so i have the local IP). So i need to check this thru some c++ coding. I am basicaly using win32 . can you please help me out. I know the api InternetGetConnectedState(), but it always gives connected ,though i have connected to LAN. Do you have any idea how to detect that....

                Birajendu SonicWALL Bangalore India

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                See here.

                "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  What URL did you try with this call? Are you able to reach that URL manually from that particular machine? Do you have a firewall? Is it configured to allow this application for outbound traffic? What does GetLastError() say?

                  It is a crappy thing, but it's life -^ Carlo Pallini

                  A Offline
                  A Offline
                  AWEIguoxin
                  wrote on last edited by
                  #8

                  :laugh:

                  1 Reply Last reply
                  0
                  • B birajendu

                    Hi, in my application i have a requirement to check the internet connection. The situation is my laptop is connected to LAN, and the outgoing internet trafiic is down(LAN is UP so i have the local IP). So i need to check this thru some c++ coding. I am basicaly using win32 . can you please help me out. I know the api InternetGetConnectedState(), but it always gives connected ,though i have connected to LAN. Do you have any idea how to detect that....

                    Birajendu SonicWALL Bangalore India

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    > I am basicaly using win32 Then you can see on Advanced Win32 ng news://nntp.aioe.org/comp.os.ms-windows.programmer.win32 or http://tinyurl.com/cmhb5g (official methods, used in Windows Shell...)

                    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