Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Internet Access Ready

23 views
Skip to first unread message

BeeJ

unread,
Apr 18, 2013, 8:45:24 PM4/18/13
to
I know how to test for Internet access using IsNetworkAlive and how to
ping but I am wondering if there might be a universal address or
addresses to ping to see if the Internet path is really active.

So, is there an IP or two to test or is there a better way to test for
a proper active connection?

I can test addresses for time but I have found that not all work all
the time so that may not be a reliable test.
I would prefer not going down a list since that might take too long.
Not sure what the best method is.

I see one of you posted this:
But it seems that as written it is only checking the local state and
not the outside, past the modem, state but I could me misreading. Is
there not more to that LFlags ?

Private Declare Function InternetGetConnectedState Lib "wininet.dll"
(ByRef dwflags As Long, ByVal dwReserved As Long) As Long

Public Function IsOnline() As Boolean
Dim LFlags As Long
IsOnline = InternetGetConnectedState(LFlags, 0&)

End Function

So bottom line a Ping seems the best most informative way.


Auric__

unread,
Apr 18, 2013, 8:51:02 PM4/18/13
to
BeeJ wrote:

> I know how to test for Internet access using IsNetworkAlive and how to
> ping but I am wondering if there might be a universal address or
> addresses to ping to see if the Internet path is really active.
>
> So, is there an IP or two to test or is there a better way to test for
> a proper active connection?

I test my ability to connect to my web host, but any top website that
responds to pings is good. Yahoo, Google, Sourceforge, etc.

--
Don't you hate it when that happens?

Karl E. Peterson

unread,
Apr 18, 2013, 9:57:05 PM4/18/13
to
BeeJ explained on 4/18/2013 :
> I know how to test for Internet access using IsNetworkAlive and how to ping
> but I am wondering if there might be a universal address or addresses to ping
> to see if the Internet path is really active.
>
> So, is there an IP or two to test or is there a better way to test for a
> proper active connection?

I'd probably choose either 8.8.8.8 or 8.8.4.4 myself.

--
.NET: It's About Trust!
http://vfred.mvps.org


Deanna Earley

unread,
Apr 19, 2013, 4:29:49 AM4/19/13
to
On 19/04/2013 01:45, BeeJ wrote:
> I know how to test for Internet access using IsNetworkAlive and how to
> ping but I am wondering if there might be a universal address or
> addresses to ping to see if the Internet path is really active.
>
> So, is there an IP or two to test or is there a better way to test for a
> proper active connection?

The usual and recommended practice is to just try and connect to
whatever you need to connect to, handling any failures.

There are situation where your test will return success but the server
fail, and the opposite where the test may fail when you'll still be able
to connect to the server.

--
Deanna Earley (dee.e...@icode.co.uk)
iCatcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored. Please reply to the
group.)

BeeJ

unread,
Apr 19, 2013, 12:54:48 PM4/19/13
to
Deanna Earley was thinking very hard :
> On 19/04/2013 01:45, BeeJ wrote:
>> I know how to test for Internet access using IsNetworkAlive and how to
>> ping but I am wondering if there might be a universal address or
>> addresses to ping to see if the Internet path is really active.
>>
>> So, is there an IP or two to test or is there a better way to test for a
>> proper active connection?
>
> The usual and recommended practice is to just try and connect to whatever you
> need to connect to, handling any failures.
>
> There are situation where your test will return success but the server fail,
> and the opposite where the test may fail when you'll still be able to connect
> to the server.

In this case doing so would require a fairly long turnaround possibly.
But I will take a look. A ping would be faster.


BeeJ

unread,
Apr 19, 2013, 12:55:12 PM4/19/13
to
Karl E. Peterson expressed precisely :
> BeeJ explained on 4/18/2013 :
>> I know how to test for Internet access using IsNetworkAlive and how to ping
>> but I am wondering if there might be a universal address or addresses to
>> ping to see if the Internet path is really active.
>>
>> So, is there an IP or two to test or is there a better way to test for a
>> proper active connection?
>
> I'd probably choose either 8.8.8.8 or 8.8.4.4 myself.

Is this the CIA or FBI or Homeland?


Gutless Umbrella Carrying Sissy

unread,
Apr 19, 2013, 2:35:07 PM4/19/13
to
BeeJ <nos...@spamnot.com> wrote in
news:kkrso3$odl$1...@dont-email.me:
Those are Google DNS servers, aren't they?

--
Terry Austin

"Terry Austin: like the polio vaccine, only with more asshole."
-- David Bilek

Jesus forgives sinners, not criminals.

RW

unread,
Apr 19, 2013, 2:46:32 PM4/19/13
to
On Fri, 19 Apr 2013 09:29:49 +0100, Deanna Earley
<dee.e...@icode.co.uk> wrote:

>There are situation where your test will return success but the server
>fail, and the opposite where the test may fail when you'll still be able
>to connect to the server.

Indeed. Not entirely the same thing but not too long ago I encountered
a situation where web access seemed unavailable. No pages would load
in the browser; I just sat staring at the spinning cursor.

But if I dropped into a command prompt window any address I pinged
returned success. It required a system reboot to get the kinks worked
out of the browser.

RW

Mayayana

unread,
Apr 19, 2013, 4:52:30 PM4/19/13
to
| > The usual and recommended practice is to just try and connect to
whatever you
| > need to connect to, handling any failures.
| >
| > There are situation where your test will return success but the server
fail,
| > and the opposite where the test may fail when you'll still be able to
connect
| > to the server.
|
| In this case doing so would require a fairly long turnaround possibly.
| But I will take a look. A ping would be faster.
|

It always *could* require a long turnaround.
If you've already tried InternetGetConnectedState
then why not just proceed? If you use async
methods you can set a timeout if you like, and
thereby provide an option to quit. What if you call
Google successfully but your target IP is slow to
respond? You could end up assuming that everything's
working but then leave the program stuck waiting.

I use async code to run whois on IPs in my server
logs each morning. Most reply very quickly. Some
never reply. I've found that 5 seconds seems to be
a good duration to wait for slow servers without hanging
my program on a non-responsive server.


Tony Toews

unread,
Apr 20, 2013, 6:01:01 PM4/20/13
to
On Fri, 19 Apr 2013 11:35:07 -0700, Gutless Umbrella Carrying Sissy
<taus...@gmail.com> wrote:

>>> I'd probably choose either 8.8.8.8 or 8.8.4.4 myself.
>>
>> Is this the CIA or FBI or Homeland?
>>
>Those are Google DNS servers, aren't they?

Close enough. <smile>

Tony

Karl E. Peterson

unread,
Apr 22, 2013, 12:13:36 PM4/22/13
to
Can't believe no one offered http://lmgtfy.com/?q=8.8.8.8&l=1 <LOL>

Gutless Umbrella Carrying Sissy

unread,
Apr 22, 2013, 2:02:42 PM4/22/13
to
Tony Toews <tto...@telusplanet.net> wrote in
news:6046n8147apc2habn...@4ax.com:
Far, far worse. The feds don't make billions from force fed
advertising.

ObiWan

unread,
Apr 23, 2013, 11:12:09 AM4/23/13
to
:: On Thu, 18 Apr 2013 17:45:24 -0700
:: (microsoft.public.vb.general.discussion)
:: <kkq433$qo7$1...@speranza.aioe.org>
:: BeeJ <spa...@nospam.com> wrote:

> InternetGetConnectedState

Call the above using the proper flags

http://stackoverflow.com/questions/14127810/check-internet-connection-with-internetgetconnectedstate-always-true

then, if still unsure, call the "InternetAttemptConnect" API

http://msdn.microsoft.com/en-us/library/windows/desktop/aa384331%28v=vs.85%29.aspx

the latter will try to activate an internet connection (if not active)
and will return the result; if the call will return "all ok", just call
the "InternetGetConnectedState" again to ensure you're online and then
do whatever you need

ObiWan

unread,
Apr 23, 2013, 11:15:21 AM4/23/13
to

> I'd probably choose either 8.8.8.8 or 8.8.4.4 myself.

Nay, I'd suggest 195.208.24.91 <vbeg>


ObiWan

unread,
Apr 23, 2013, 11:21:34 AM4/23/13
to

> Private Declare Function InternetGetConnectedState Lib "wininet.dll"
> (ByRef dwflags As Long, ByVal dwReserved As Long) As Long
>
> Public Function IsOnline() As Boolean
> Dim LFlags As Long
> IsOnline = InternetGetConnectedState(LFlags, 0&)
>
> End Function

the return code just tells you if the system HAS an Internet
connection, NOT if such a connection IS active

http://msdn.microsoft.com/en-us/library/windows/desktop/aa384702%28v=vs.85%29.aspx

so, as I wrote in another post here, you'd better mix the above call
with an "InternetAttemptConnect()" one; basically the idea is

Call "InternetGetConnectedState" to check if the system HAS an internet
connection (check the returned flags to verify that, not just the call
result code); if not, just return false, otherwise, if the system HAS
an internet connection, try calling "InternetAttemptConnect" the latter
will either return immediately with a "true" if the internet connection
is active or, if not, will attempt establishing an internet connection;
if the call will fail, again, return a "not connected", otherwise just
use the "InternetGetConnectedState" again to check how the system is
connected and this time, return your result






CoderX

unread,
Apr 23, 2013, 4:11:42 PM4/23/13
to

"Karl E. Peterson" <ka...@exmvps.org> wrote in message
news:kl3ndr$1jn$1...@dont-email.me...
>
> Can't believe no one offered http://lmgtfy.com/?q=8.8.8.8&l=1 <LOL>

Yeah, that would mean beej would have to use google. That would like asking
a vampire to press a cross on his forehead.


BeeJ

unread,
Apr 23, 2013, 9:11:50 PM4/23/13
to
ObiWan presented the following explanation :
Thanks I will try that too.


ObiWan

unread,
Apr 24, 2013, 4:42:29 AM4/24/13
to

> > Call "InternetGetConnectedState" to check if the system HAS an
> > internet connection (check the returned flags to verify that, not
> > just the call result code); if not, just return false, otherwise,
> > if the system HAS an internet connection, try calling

a note; if the flags returned by "InternetGetConnectedState" include
the "RAS" bit, consider that calling "InternetAttemptConnect" if the
"RAS" bit is set and if the call returned "false" (connection not
active) may (and probably will) popup a "dial up" dialog asking the user
to activate the connection

0 new messages