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

x
?
Solved

How do I detect whether of not an Internet connection exists?

Posted on 1997-04-06
6
Medium Priority
?
182 Views
Last Modified: 2010-04-06
My problem is that I need to test whether or not a connection to the internet exists in windows95.  The obvious solution is to test your own IP address and compare it to 127.0.0.1 .  If the comparison is true, your offline.  Any other IP address means your online.

The problem is that with windows95, any call to winsock triggers the dialer.  I DO NOT want to trigger the dialer if there is no connection to the internet.

So, I guess my question is:

   How do I make a call to Winsock without triggering the dialer?

0
Comment
Question by:sleach
[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
  • 4
  • 2
6 Comments
 
LVL 1

Author Comment

by:sleach
ID: 1335217
Edited text of question
0
 
LVL 1

Author Comment

by:sleach
ID: 1335218
Adjusted points to 204
0
 
LVL 3

Accepted Solution

by:
sperling earned 400 total points
ID: 1335219
Might work using the RasEnumConnections API call...

If you need help using this function, let me know.

Regards,

Erik.
0
Industry Leaders: 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!

 
LVL 1

Author Comment

by:sleach
ID: 1335220
sperling, I am unfamiliar with RAS.  Can you point me to a code example?  

Also, will RasEnumConnections show only dial up networking connections, or will it also show connections from other dialers(such as AOL's 32 bit dialer)?

I am currently using FindWindow to detect the Win95 Dialer, but this only works with the Win95 Dialer.  I need a method thats Dialer independant.

Can RAS be used to disable the AutoDial feature?
0
 
LVL 3

Expert Comment

by:sperling
ID: 1335221
>sperling, I am unfamiliar with RAS. Can you point me to a code
>example?

So am I ;)

I haven't got any modems installed, and I don't run 95... Therefore I can just suggest that you make a small test program displaying RasEnumConnections output in an ButtonClick event, and then tries to figure out how it works by noting what output you get while offline and online using different dialers.

Sorry I can't be of more help.

Regards,

Erik.
0
 
LVL 1

Author Comment

by:sleach
ID: 1335222
It took me awhile, but I finally figured it out.

For the purpose of sharing the solution, Here is the function that works for me.

USES ras;

function RasConnected:  boolean;
var
    rasconnbuf:  TRasConn;
    cb, ret, numConn:  integer;
    connected:  boolean;
begin

    //Required to provide buffer size
    rasconnbuf.dwSize := sizeof(rasconnbuf);
    cb := sizeof(TRasConn);

    //Retrieve info about first active connection (I only have one - change this if you have more)
    ret := RasEnumConnections(@rasconnbuf, cb, numConn);

    if ((numConn = 0) or (ret <> 0)) then connected := false
    else Connected := true;
result := connected;
end;

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

715 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