Detecting presence of Internet connection

P

Peter Flynn

I'm having trouble finding example code to detect the presence of
an Internet connection. It doesn't seem to be a very frequently
asked question, as all I need is the answer yes or no (is the user
connected or not). I'm not interested in speed detection or any
other aspect of the connection, just its existence or not. The
reason is to be able to intercept link clicks on a CD-based set
of HTML pages and pop up a warning if there is no connection;
otherwise pass the request through to the net.

///Peter
 
I

Ivan Marsh

I'm having trouble finding example code to detect the presence of an
Internet connection. It doesn't seem to be a very frequently asked
question, as all I need is the answer yes or no (is the user connected
or not). I'm not interested in speed detection or any other aspect of
the connection, just its existence or not. The reason is to be able to
intercept link clicks on a CD-based set of HTML pages and pop up a
warning if there is no connection; otherwise pass the request through to
the net.

How would you intend to determine between having an IP address on a LAN
and having a connection on to the internet without pinging an address on
the internet?

The easiest way is to ask the user: Do you have a connection to the
internet?

--
The U.S. Government today announced that it is changing its emblem from an
Eagle to a CONDOM because it more accurately reflects the government's
political stance... A condom allows for inflation, halts production, destroys
the next generation, protects a bunch of pricks, and gives you a sense of
security while you're being screwed.
 
P

Peter Flynn

Ivan said:
How would you intend to determine between having an IP address on a LAN
and having a connection on to the internet without pinging an address on
the internet?

For the specific application the users involved either have Internet
access or they are offline completely (eg using a laptop out of range
of wireless, phone, etc), so the state of being on the LAN but without
Internet access won't arise (fortunately).
The easiest way is to ask the user: Do you have a connection to the
internet?

The publisher is against this...

///Peter
 
R

RobG

Peter said:
I'm having trouble finding example code to detect the presence of
an Internet connection. It doesn't seem to be a very frequently
asked question, as all I need is the answer yes or no (is the user
connected or not). I'm not interested in speed detection or any
other aspect of the connection, just its existence or not. The
reason is to be able to intercept link clicks on a CD-based set
of HTML pages and pop up a warning if there is no connection;
otherwise pass the request through to the net.

///Peter

I think your real requirement is to detect if a particular resource is
avaialble or not - whether the user has access to the internet or not
is moot. Access to the URI could be blocked for any number of reasons
unrelated to general internet access. Resources may be in different
domains; some local, others not.

There are detailed instruction at the link below, with code, to detect
whether the user can access a particular URI. Create a 'can my
function access this URI' function based on the code provided and you
will have a much more robust function that doesn't care about how or
whether the user is connected to internet:

<URL:http://www.xml.com/pub/a/2005/02/09/xml-http-request.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top