Solved

Knowing if have access to "Net" via Cable Modem?

Posted on 1999-01-17
6
183 Views
Last Modified: 2013-11-13
I have set a feature in my program that uses the Winsock control to be able to reconnect to the internet if disconnected. This is for a DUN (Dialup network) connection. How i do this is by a timer which fires every 30 secs to check if the DUN connection is still established.
This works fine BUT if the user has a Cable Modem it the program will think that since it is not connected via DUN that it is not connected to the net, however, with a cable modem you are always connected to the internet. Is there a check i can do to see if the user has ANY kind of internet connection (besides DUN) and if he/she does and the connection is lost i want to be able to pop up an error message indicating connection was lost.  Thanks
0
Comment
Question by:ljaques
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:carlosvs
ID: 1469103
How can you check the DUN?
0
 

Author Comment

by:ljaques
ID: 1469104
Carlosvs:
Leave me your email address here and i will send you my code on how to do this..Example and all.

0
 
LVL 2

Expert Comment

by:PedroG
ID: 1469105
i gues not!! i've were searching for something like that, and found no way to do it.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:ljaques
ID: 1469106
PedroG,
  I was goofing around and i notice that if you set a timer control to check every 30 secs at the Winsock1.LocalIP address you can see that the address is not "127.0.0.1" or "" and if it is not then that means you are connected to some network (hopefully the internet). If connection is lost then the LocalIP auto goes back to "127.0.0.1" or "".  Maybe this is a fluke accident but it seems to work for me right now
0
 
LVL 1

Expert Comment

by:carlosvs
ID: 1469107
It will be very usefull my email is
al532527@campus.sin.itesm.mx
thanks.
0
 

Accepted Solution

by:
BoHey earned 20 total points
ID: 1469108
Try this:

In Form/Standard Module:
----------------------------------------------------------------
Option Explicit

Private Const INTERNET_CONNECTION_MODEM = 1
Private Const INTERNET_CONNECTION_LAN = 2
Private Const INTERNET_CONNECTION_PROXY = 4
Private Const INTERNET_CONNECTION_MODEM_BUSY = 8

Declare Function InternetGetConnectedState Lib "wininet.dll" _
                 (lpdwFlags As Long, _
                  ByVal dwReserved As Long) _
                 As Boolean

Function call:
----------------------------------------------------------------
Private Sub cmdGetConnectState_Click()
 Dim bConnected As Boolean
 Dim lConDescr As Long
 
 bConnected = InternetGetConnectedState(lConDescr, 0&)
   
 If bConnected Then
  Select Case lConDescr
   Case lConDescr And INTERNET_CONNECTION_MODEM
    Debug.Print "InetConnect via Modem"
   Case lConDescr And INTERNET_CONNECTION_LAN
    Debug.Print "InetConnect via Lan"
   Case lConDescr And INTERNET_CONNECTION_PROXY
    Debug.Print "InetConnect via Proxy"
   Case lConDescr And INTERNET_CONNECTION_MODEM_BUSY
    Debug.Print "Modem busy"
   Case Else
    'Void...
   End Select
  Else
   Debug.Print "No Connection."
  End If
End Sub

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question