Checking for active internet connection. 
Author Message
 Checking for active internet connection.

I'm looking for a good way to check for an active internet connection using
Visual Basic 6.

Thanks in advance.
- Gregg



Fri, 04 Mar 2005 14:13:14 GMT  
 Checking for active internet connection.

Quote:

>I'm looking for a good way to check for an active internet connection using
>visual basic 6.

>Thanks in advance.
>- Gregg

There does not seem to be a satisfactory general solution to this
problem. RasGetConnectStatus() indicates if a dial up connection
exists. Users who connect via a LAN or directly via cable or ADSL pose
a much more difficult problem.The code at
http://www.mvps.org/vbnet/code/network/internetgetconnectedstate.htm
provides most of what you need but InternetGetConnectedState() returns
True whether or not the user is logged in to the ISP. This is correct
in the sense that the user must be "connected" otherwise she could not
log in but the connection is not very useful if your program wants to
connect to a specific site.

In an application I wrote I chose to remain silent if the user had an
active dial up connection and display a vague message like "Please
ensure your internet connection is established." otherwise. An
alternative is to try doing whatever it is that you need to do and
assume that a failure indicates you are not connected. This can either
be very irritating to the user because a failure can require a few
seconds or expensive to code because it needs a separate thread.



Fri, 04 Mar 2005 22:31:18 GMT  
 Checking for active internet connection.

Quote:
>I'm looking for a good way to check for an active internet connection using
>visual basic 6.

Look at InternetGetConnectedState or InternetGetConnectedStateEx
MSDN has the info.

--
Regards, Frank



Fri, 04 Mar 2005 22:38:57 GMT  
 Checking for active internet connection.

Quote:
>I'm looking for a good way to check for an active internet connection using
>visual basic 6.

>Thanks in advance.

This is a frequently asked question, and one that has a number of
"sort of" type of answers. The only way to know for sure if they can
connect to the server is to actually attempt the connection;
everything else is some degree of guesswork (for example, telling the
difference between then not having a physical network connection, or
something like a pulled cable or a down router). That said, I would do
something like the following:

1. Check to see if they have any dial-up networking connectoids
defined. If they do, you can be fairly certain they have a dial-up
connection. This isn't guaranteed to be the case (for example, it
could be a special dialup to a corporate network), but in most cases
it would be a good guess.

2. If they do have one or more connectoids, then check to see if there
is a current, active dial-up networking session using the RAS API. If
there is, then make note of it, and which one they're using.

3. Attempt to send an ICMP echo datagram to the remote host; if you
get a response, then they're up on the net. If you don't, then one of
three things could be the case (a) they're using a dial-up and aren't
connected; check the information in step 2; (b) they're not using a
dial-up and the interface or router is down; (c) the remote host does
not respond to ICMP ECHO datagrams. If the situation is (a), then
prompt them to establish a connection and try again; if it is (b)
there's not much you can do, and (c) is a situation in which this
would never work.

4. Finally, make the connection attempt with a reasonable timeout
period.

As you can see, steps 1 through 3 can give you some flexibility in
determing what kind of connection exists, but not what isn't there. In
all cases, you may just have to "punt" and make the connection attempt
directly. As far as the coding for this goes, you could either use the
RAS and Windows Sockets API directly, a control or a set of components
like our commercial SocketTools product that includes ICMP and RAS
controls.

David

----

Catalyst Development Corporation   | application with ActivePatch. Download
http://www.catalyst.com/           | the SDK from www.activepatch.com



Sat, 05 Mar 2005 11:32:49 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. NT4.0 and RAS, Checking for active connection

2. Checking for Active TCP/IP connection with out RAS

3. How do I detect an active internet connection?

4. test for active internet connection with VBScript?

5. Active Internet Connection - Determining If User Has

6. How do I detect an active internet connection?

7. Active Internet Connection

8. Test for active internet connection

9. How do I detect an active internet connection?

10. Active internet connection

11. Determine if Active Internet Connection Exists

12. detecting active internet connection

 

 
Powered by phpBB® Forum Software