473,503 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting presence of Internet connection

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

Oct 27 '05 #1
4 2795
On Thu, 27 Oct 2005 22:38:47 +0100, Peter Flynn wrote:
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.

Oct 27 '05 #2
Ivan Marsh wrote:
On Thu, 27 Oct 2005 22:38:47 +0100, Peter Flynn wrote:
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?


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
Oct 27 '05 #3
Peter Flynn wrote:
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>
--
Rob

Oct 28 '05 #4
In article <3s************@individual.net>,
Peter Flynn <pe********@m.silmaril.ie> wrote:
Ivan Marsh wrote:
On Thu, 27 Oct 2005 22:38:47 +0100, Peter Flynn wrote:
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?


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


In that case a fairly quiet way to go about this might be to do an
XMLHttpRequest for something -- anything, really -- in the background.
If it returns meaningful data, you can conclude they have a connection.
If it doesn't, you can conclude that they either don't or that something
is wrong at the other end. In either case, if you are dealing with just
the client's servers, you know you are down, though you might want to
phrase the user info carefully, i.e.: Your internet connection is not
active or there is an issue with the server. Please contact such and
such if you feel this message is in error...
Oct 28 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2557
by: Matt Hawley | last post by:
I'm facing a problem where I need to verify that my windows forms application has access to the internet before it can do anything. Currently, the only way I can think of is by creating a...
3
6609
by: Jonny | last post by:
Hi, Please could you tell me how to check for an internet connection in C. I'm using Windows 2000. Many Thanks, Jonny
0
908
by: Woo Mun Foong | last post by:
HI, How do I know whether my PC is already connected to the Internet and not only the LAN ? My program needs to send an email back from my remote PC to my HQ according to schedule. Can I...
3
4037
by: danielmcinerney | last post by:
i am trying to set up internet connection sharing between a vista machine (host) and an XP machine (client). i have followed guidelines from various pages on the internet but i still cannot get it...
6
3118
by: =?Utf-8?B?QnNtZW5nZW4=?= | last post by:
I am trying to make sure that the local connection is up. I have presently been using the NetworkChange.NetworkAvailabilityChanged Event for this. Is there a better way to do this? Also, I...
0
1150
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, I m facing a big problem... How can i detect that either the internet connection id dialup or is on LAN or is their both connection exists...... and what is the connection speed. And is...
1
2240
by: =?Utf-8?B?QiBTaW5naA==?= | last post by:
Hi Scenario 1) Host - XP Laptop with internet connection using Sky Broadband Wireless Router Netgear DG834GT 2) MS Virtual Server 2005 - I have deployed an XP MS Virtual Server 2005 to act...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5594
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4688
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.