473,396 Members | 2,140 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,396 software developers and data experts.

Web Connections

Does .net Framework 2.0 have anything new to help us detect if a user has an
active internet connection and to send a notice when a connection is
established or dropped?

Thanks,

Dennis
Dec 1 '05 #1
6 4211
Hi,
AFAIK there is no way to know it, you could use some workaround like
1:- Try to establish a connection to a know website (useless if a mandatory
proxy is in place)
2- Try to make a ping to some remote computer (useless if a firewall is
present)
3- Try to resolve a name ( this IMO is the more sure way )
Other than that I cannot think of another way.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dennis C. Drumm" <dc******@community.nospam> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
Does .net Framework 2.0 have anything new to help us detect if a user has
an active internet connection and to send a notice when a connection is
established or dropped?

Thanks,

Dennis

Dec 1 '05 #2
Nothing built in other than attempting a download via HttpWebRequest.
However, with an API, its easy:

[DllImport(@"C:\Windows\System32\wininet.dll")]
// this method will check the internet connection state
public static extern bool InternetGetConnectedState(ref uint connected, uint
reserved);

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dennis C. Drumm" wrote:
Does .net Framework 2.0 have anything new to help us detect if a user has an
active internet connection and to send a notice when a connection is
established or dropped?

Thanks,

Dennis

Dec 1 '05 #3
Hi Dennis,
Welcome to MSDN Newsgroup!

From my experience, there is no notified message which will be sent when
user has an active internet connection. If we want to get current internet
information, I suggest you to call some APIs (for example:
InternetCheckConnection, InternetGetConnectedStateEx ) in WinInet using
P/Invoke mechanism.

I hope the above information is helpful for you. If you have any questions
or concerns, please let me know. Thanks again and have a nice day!

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Dec 2 '05 #4
One word of warning; InternetGetConnectedState is easily confused and can
report an internet connection when there isn't one. It's a good first check,
but you need to do more.

In my old VB6 apps, I use InternetGetConnectedState to make the first check
and, if it reports that there is an internet connection, I attempt to
connect to a known FTP site (our company web site, actually) and only if
that connection can be established do I take it as proof that there is an
internet connection.

Steve
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:60**********************************@microsof t.com...
Nothing built in other than attempting a download via HttpWebRequest.
However, with an API, its easy:

[DllImport(@"C:\Windows\System32\wininet.dll")]
// this method will check the internet connection state
public static extern bool InternetGetConnectedState(ref uint connected,
uint
reserved);

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dennis C. Drumm" wrote:
Does .net Framework 2.0 have anything new to help us detect if a user has
an
active internet connection and to send a notice when a connection is
established or dropped?

Thanks,

Dennis

Dec 2 '05 #5
It appears that a new class for .net framework 2.0 is PingReply and by using
the Status property one can determine if some known web site is accessible.

This would seem to do the trick and I think would avoid the annoying side
affect of causing someone's computer that only has a dialup connection to
try to connect without being asked to.

What do you all think?

Dennis
"Steve Barnett" <no****@nodomain.com> wrote in message
news:OF**************@TK2MSFTNGP14.phx.gbl...
One word of warning; InternetGetConnectedState is easily confused and can
report an internet connection when there isn't one. It's a good first
check, but you need to do more.

In my old VB6 apps, I use InternetGetConnectedState to make the first
check and, if it reports that there is an internet connection, I attempt
to connect to a known FTP site (our company web site, actually) and only
if that connection can be established do I take it as proof that there is
an internet connection.

Steve
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:60**********************************@microsof t.com...
Nothing built in other than attempting a download via HttpWebRequest.
However, with an API, its easy:

[DllImport(@"C:\Windows\System32\wininet.dll")]
// this method will check the internet connection state
public static extern bool InternetGetConnectedState(ref uint connected,
uint
reserved);

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dennis C. Drumm" wrote:
Does .net Framework 2.0 have anything new to help us detect if a user
has an
active internet connection and to send a notice when a connection is
established or dropped?

Thanks,

Dennis


Dec 2 '05 #6
Hi Dennis,
Nice to see you again!
PingReply could help us get the status of an attempt to send an Internet
Control Message Protocol (ICMP) echo request and receive the corresponding
ICMP echo reply message. We could determine whether or not some web site is
accessible depending on this status.
Thanks for your sharing knowledge. It will benefit others in the newsgroup
facing this issue.

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Dec 5 '05 #7

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

Similar topics

3
by: Randell D. | last post by:
Folks, I currently connect to my db with PHP code that uses non-persistent connections. I've read that persistent connections can help performance since a connection to the db will use an...
3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
4
by: Angelos | last post by:
I get this error mysql_pconnect Too many connections ... every now and then. Does anyone knows where it comes from ? There are a lot of sites running on the server and all of them use the...
1
by: C Sharp beginner | last post by:
I'm sorry about this verbose posting. This is a follow-up to my yesterday's posting. Thanks William for your reply. I understand it is a good practice to open connections as late as possible and...
2
by: Bob | last post by:
We have a production web site that's data intensive (save user input to DB and query for displaying) with the ASP.NET app part on one W2K server and SQL 2000 DB on another W2K server. I have set...
17
by: Peter Proost | last post by:
Hi Group, I've got an interesting problem, I don't know if this is the right group but I think so because everything I've read about it so far says it's a .net problem. Here's the problem, we're...
4
by: elyob | last post by:
Not really tried going two ways at once, but I have an include_once connection to a mysql_database, now I need to retrieve info from a second mysql_database .. My mysql_connects are getting...
1
by: marcfischman | last post by:
Please help. I have a website running on a linux/apache/mysql/php server. I receive about 8,000-10,000 visitors a day with about 200,000 to 300,000 page views. The server is a RedHat Linux...
13
by: PRP | last post by:
Hi, Our DBA has complained about the large number of connections from the aspnet_wp process. We have multiple web applications deployed in different virtual directories. I read that the way...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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,...

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.