Checking Internet connectivity

Results 1 to 3 of 3

Thread: Checking Internet connectivity

  1. #1
    Join Date
    Dec 1969

    Default Checking Internet connectivity

    Hello,<BR><BR>I&#039m adding a links page to an existing Intra-net website. Only some of the people are able to connect to the Internet, though, and I would like to check if the end user is enable to connect to the Internet, and if he doesn&#039t, then he should get another page. My question is therefore how do I check the connectivity? <BR><BR>Thanks in advance,<BR>John

  2. #2
    manjula Guest

    Default RE: Checking Internet connectivity

    Hope this article will help you. it is from MSDN library.<BR><BR>HOWTO: Detecting If You Have a Connection to the Internet <BR><BR>The information in this article applies to:<BR><BR>Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5<BR><BR>SUMMARY<BR>Many of you want to know if a computer has an active Internet connection before trying to connect to the Internet using the WinInet API or some other communication interface. The internet connection is important if you don&#039t want your application to cause Windows to automatically dial the default Internet modem connection.<BR><BR>This article provides a mechanism for determining if an Internet site is accessible without the risk of you being prompted to dial into another Internet Service Provider. <BR><BR>MORE INFORMATION<BR>Usually the best way to determine if you have a connection to a particular computer is to attempt the connection. If the autodial feature of Windows is enabled then attempting the connection may cause the default Internet dialup connectoid to be opened, and you will be prompted with your credentials to connect.<BR><BR>To avoid having the default Internet connectoid dialed, the InternetGetConnectedState function can be used to determine if there is a default Internet dialup connectoid configured and whether it is currently active or not. If there is a default Internet dialup connectoid configured and it is not currently active then InternetGetConnectedState will return FALSE. If InternetGetConnectedState returns TRUE then you can attempt to connect to the Internet resource without fear of being prompted to connect to another Internet Service Provider.<BR><BR>The following code demonstrates how you would do this:<BR><BR>if (InternetGetConnectedState(...) == FALSE)<BR>{<BR> // Don&#039t attempt connection or it will bring up the dialog<BR> ...<BR>}<BR>else<BR>{<BR> //Attempt connection<BR> if (InternetOpenURL(...) == NULL)<BR> {<BR> // Call failed<BR> err = GetLastError();<BR> if ((err == ERROR_INTERNET_NAME_NOT_RESOLVED) &#124&#124<BR> (err == ERROR_INTERNET_CANNOT_CONNECT) &#124&#124<BR> (err == ERROR_INTERNET_TIMEOUT))<BR> {<BR> // probably not connected...handle appropriately<BR> ...<BR> }<BR> }<BR> // We&#039re connected!!!<BR> ....<BR>}<BR><BR>You cannot rely solely on the fact that InternetGetConnectedState returning TRUE means that you have a valid active Internet connection. It is impossible for InternetGetConnectedState to determine if the entire connection to the Internet is functioning without sending a request to a server. This is why you need to send a request to determine if you are really connected or not. You can be assured however that if InternetGetConnectedState returns TRUE, that attempting your connection will NOT cause you to be prompted to connect to the default Internet Service Provider.<BR><BR>Be aware that InternetGetConnectedState only reports the status of the default Internet connectoid on Internet Explorer 4.x. If a nondefault connectoid is connected, InternetGetConnectedState always returns FALSE (unless a LAN connection is used). With Internet Explorer 4.x configured to use a LAN connection, InternetGetCo nectedState always returns TRUE.<BR><BR>Internet Explorer 5 behaves differently. If you are currently dialed into a different dial-up in Internet Explorer 5, InternetGetConnectedState reports dial-up connection status as long as any connectoid is dialed or an active LAN connection exists. <BR><BR>There are some other ways to try to determine if you currently have a connection to a particular network resource. The IsDestinationReachable() function can be used to find out if there is a current connection to an address. However, he IsDestinationReachable() function is only concerned with whether the IP address is reachable from your computer. It does not work through HTTP proxies or firewalls that restrict ICMP ping packets.<BR><BR>It is also possible to use RasEnumConnections to enhance your code so that you can tell if there is an active dialup connection that might have Internet access even though it is not the default Internet dialup connectoid. <BR>

  3. #3
    Jogn Guest

    Default Ok, thanks a lot :-)

    I will give it a try<BR><BR>Best regards<BR>John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts