Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1999-01-17
6
Medium Priority
?
184 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
Technology Partners: 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!

 

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 40 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

704 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