Solved

checking internet connection

Posted on 2003-11-01
7
252 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
[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
  • 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

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

Suggested Solutions

Title # Comments Views Activity
iSeries DB2 Query 2 98
conditional code and condition difference 9 84
child constructor and parent constructor, overriding and overloading 6 93
Fibonacci challenge 11 136
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

756 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