Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Detecting existence of internet connection

Short answer - No.

Long answer - You could use PING and see if you get a response from a
known server on the interwebs. Or COPY a known page from a web server or
FTP server.

I am assuming by "internet connection" you mean that you have a valid LAN
connection and IP address but you may or may not have a valid WAN
connection.

-Scott

Steve F$BaC(Bi$BaO(B <> wrote on 07/27/2010 03:58:36 PM:


> Is there a simple way to detect whether or not an internet connection is


> available?
> --
> Steve
>
>
>
>
>
>
>
 
| Short answer - No.
|
| Long answer - You could use PING and see if you get a response from a
| known server on the interwebs. Or COPY a known page from a web
| server or FTP server.
|
| I am assuming by "internet connection" you mean that you have a
| valid LAN connection and IP address but you may or may not have a
| valid WAN connection.

Thanks for the reply. The issue is esp. pertinent to any mobile
computer,e.g. a laptop computer with built-in WiFi. When you start it, you
want to start browsers, mail clients, etc. only if you are connected to the
WWW.
The problem with testing internet availability with PING or any other
check against a single URL is that the specific URL may be down. OTOH I can
ping many sites, and on detecting the first response declare that I am
connected.
--
Steve
 
On Tue, 27 Jul 2010 15:58:37 -0400, Steve Fábián
<> wrote:

|Is there a simple way to detect whether or not an internet connection is
|available?

IPCONFIG /ALL will tell you if Windows **thinks** there's an internet
connection. %_IP is probably just as good for that. But you won't
know if it's usable until you try it ... @PING, perhaps.
 
| IPCONFIG /ALL will tell you if Windows **thinks** there's an internet
| connection. %_IP is probably just as good for that. But you won't
| know if it's usable until you try it ... @PING, perhaps.

Whether or not my cable modem is connected to my router the reports of
both IPCONFIG /ALL and ECHO %_IP are the same. @PING works, but is dependent
on the accessibility of the specified URL. One could try many, and if any
one works, assume the connection exists, but it is timeconsuming even for
one failure.
Interestingly, the WinXP Control Panel applet "Network Connections"
detects a newly made connection, but does not detect disconnection. I'll try
to see if one of the NET.EXE subcommands can be used for this purpose.
--
Steve
 
| IPCONFIG /ALL will tell you if Windows **thinks** there's an internet
| connection. %_IP is probably just as good for that. But you won't
| know if it's usable until you try it ... @PING, perhaps.

Whether or not my cable modem is connected to my router the reports of
both IPCONFIG /ALL and ECHO %_IP are the same. @PING works, but is dependent
on the accessibility of the specified URL. One could try many, and if any
one works, assume the connection exists, but it is timeconsuming even for
one failure.
Interestingly, the WinXP Control Panel applet "Network Connections"
detects a newly made connection, but does not detect disconnection. I'll try
to see if one of the NET.EXE subcommands can be used for this purpose.
--
Steve
It doesn't have to be all that time consuming. Specify some address that's extremely likely to be there, like your ISP's default router, and a timeout and one iteration, like
Code:
ping -n 1 -w 1000 somewhere.close.com
 
So my assumptions were wrong. You need to know when you have a valid IP
address. That can be tricky. Many WiFi hotspots will require you to
login or at least acknowlege/dismiss an acceptable use page.

So you need to associate with the hotspot, then launch a web browser and
do whatever pops up on that screen. Then you can launch all your apps.

If you don't need to do any of that, then you could use IPCONFIG or %_IP
to see if you have a valid IP address. If it starts with 169.x.x.x then
you have an auto-assigned address that is not valid.

-Scott

Steve F$BaC(Bi$BaO(B <> wrote on 07/27/2010 04:46:55 PM:


> | Short answer - No.
> |
> | Long answer - You could use PING and see if you get a response from a
> | known server on the interwebs. Or COPY a known page from a web
> | server or FTP server.
> |
> | I am assuming by "internet connection" you mean that you have a
> | valid LAN connection and IP address but you may or may not have a
> | valid WAN connection.
>
> Thanks for the reply. The issue is esp. pertinent to any mobile
> computer,e.g. a laptop computer with built-in WiFi. When you start it,
you

> want to start browsers, mail clients, etc. only if you are connected to
the

> WWW.
> The problem with testing internet availability with PING or any
other

> check against a single URL is that the specific URL may be down. OTOH I
can

> ping many sites, and on detecting the first response declare that I am
> connected.
> --
> Steve
>
>
>
>
 
The problem with testing internet availability with PING or any other check against a single URL is that the specific URL may be down. OTOH I can ping many sites, and on detecting the first response declare that I am connected.

In the past, I have used something like:

Code:
if %@ping[google.com,3] lt -1 if %@ping[microsoft.com,3] lt -1 abort No internet connection!

If both Google and Microsoft are unreachable, then something is deeply wrong. ("Google is the web, and is the web in flames? No!")
 
Windows Vista and 7 can tell if Internet access is available. I'm not sure what method it uses, but maybe there is a way to query the OS...
 
On Tue, 27 Jul 2010 17:58:02 -0400, Charles Dye
<> wrote:

|---Quote (Originally by Steve Fábián)---
| The problem with testing internet availability with PING or any other check against a single URL is that the specific URL may be down. OTOH I can ping many sites, and on detecting the first response declare that I am connected.
|---End Quote---

Do a TRACERT (to anywhere) and note the first (real/routable/outside
your home) IP along the route. Use that as the target of a PING. If
that one is down, it's a good bet you don't have a (usable) internet
connection. For example,

Code:
v:\> tracert -d -h 2 ilucky

Tracing route to lucky.syr.edu [128.230.13.36]
over a maximum of 2 hops:

  1     7 ms     5 ms     5 ms  10.236.192.1
  2    15 ms    11 ms    12 ms  24.92.246.125

Trace complete.

v:\> echo %@ping[24.92.246.125]
12

That's no guarantee that you can reach anything on the greater
internet but is does indicate that there's no problem at your end.
 

Similar threads

Back
Top