473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Test connection with internet



HI...

I'm making a program to test f my connection to the internet was
alive... I think of make a webrequest and ersponse, but even if my
connection is down doesn't I get a response??? The error 404...

Does you all have an Idea how can I do that???
thx...

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
1 2901
Hi Ricardo,
if you want to use a webrequest and response to test the internet
connection you could do something like the following, you know that you are
not connected because you will not be alble to resolve the web url and an
exception will be thrown:

bool blnConnected = false;

//choose a site you can count on be up most of the time
HttpWebRequest wr =
(HttpWebRequest)WebRequest.Create("http://www.google.com");

try
{
//try to get response from the website
HttpWebResponse wresp = (HttpWebResponse)wr.GetResponse();

if(wresp.StatusCode == HttpStatusCode.OK)
{
blnConnected = true;
}
}
catch(System.Net.WebException exc)
{
//this will happen if you cannot connect to the site
blnConnected = false;
}
finally
{
wresp.Close();

if(blnConnected)
{
//do connected action
}
else
{
//do unconnected action
}
}
"Ricardo Luceac" wrote:


HI...

I'm making a program to test f my connection to the internet was
alive... I think of make a webrequest and ersponse, but even if my
connection is down doesn't I get a response??? The error 404...

Does you all have an Idea how can I do that???
thx...

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #2

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

Similar topics

4
by: Peter Flynn | last post by:
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...
3
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
by: Ricardo Luceac | last post by:
HI... I'm making a program to test f my connection to the internet was alive... I think of make a webrequest and ersponse, but even if my connection is down doesn't I get a response??? The error...
2
by: Mahesh Devjibhai Dhola | last post by:
Hi, I want to develop p2p (peer-to-peer) communication connection for chat in ..Net (Lang: c# - preferable) NOTE: if two LAN are behind their own router then also it should work as yahoo, msn...
15
by: ezmiller | last post by:
Does anybody know how to use javascript to test whether or not an internet connection exists? Is this possible even?
4
by: John Riddle | last post by:
Hello, I have an application that runs continously gives an error and stops working if the internet goes down (which happens for about 5-10 minutes several times a day. Can anybody tell me how...
4
by: adalton | last post by:
I've been trying to figure out how to test for a valid internet connection. I am able to connect to a valid internet connection, but when it drops, or if it is not there when my program starts, I...
3
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...
1
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.