Solved

checking internet connection

Posted on 2003-11-01
7
221 Views
Last Modified: 2013-11-20
hi guys,
 i need to check whether the internet connection is available or not.i tried RAS APi and some method.but none of them are not reliable.
is there any alternative method for that one...
thx in advance
regards
prakash
0
Comment
Question by:vjayaprasen
  • 2
  • 2
7 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 9662541
There is no such thing as an "internet connection".  The internet is a concept not a thing to be connected to.

What you are therefore asking is impossible to answer.

What I THINK you are asking, but am somewhat unsure due to the ambiguity in your question is:

"How do I know if my computer is actively connected to some network that can reach a remote host?"

If that is really your question then I have some suggestions.  But how to proceed depends on HOW you connect your computer to a network.  There are TWO basic ways:

1) DIAL UP (in Windows terminology, RAS)

2) Wired (or WIRELESS) LAN

Any other type you think you have really is based on one of these two.

1) If you are interested in RAS, the RAS API will tell you EVERYTHING you need to know about the specific RAS connection.  What is will NOT tell you is whether or not you can connect to some remote host.  The ONLY way to know that is to TRY IT.  If it works, the answer is YES, if it fails the answer is NO.  Got it?

2) If you are interested in LAN, there is not a GENERAL Windows API for this.  Different versions of Windows have different capabilities.  So without knowing your platform, I can't give you any specific advice other than to first determine if you are operating in RAS connection.  If not, then a LAN connection is possible.  To determine if you can connect to a remote host or not, use the SAME method as with RAS.  TRY the connection and see if it works.

Keep in mind that even if the connection works NOW, it may NOT work later.  Networks are funny things and they come and go as they please.  So if you are building some application that depends on some sort of network connection, you MUST employ coding practices that anticipate network failure at ANY TIME.  To do otherwise will make your application unstable and very annoying to your users.

If I've misinterpreted your question, please clarify yourself.
0
 
LVL 8

Expert Comment

by:martynjpearson
ID: 9663528
You might want to check out the API functions InternetGetConnectedState() or InternetCheckConnection(). See
http://msdn.microsoft.com/library/en-us/wininet/wininet/internetgetconnectedstate.asp
and
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/internetcheckconnection.asp

Hope this helps
Martyn
0
 
LVL 32

Expert Comment

by:jhance
ID: 9663872
Martyn,

You may want to study what these APIs actually do before recommending them in a situation like this...
0
 
LVL 8

Expert Comment

by:martynjpearson
ID: 9665710
I have to admit my suggestion about using InternetGetConnectedState() was based on some research I did onto the problem when wishing to do something similar in one of my own applications, rather than actual experience. I've had a hunt and found the document I found when looking into the problem before :

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q242/5/58.ASP&NoWebContent=1

It describes the use of the function, however, the article does say exactly what you said above - the only way to be sure there is a connection is to try and use it.

Best regards
Martyn
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 44
Hibernate methods 2 58
EvenOdd challenge 10 83
fix34  challenge 9 97
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now