Checking internet connection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

From a desktop application, i want to check if an internet connection exist.
Many articles use the win api "InternetGetConnectedState", but it is no sure
thing.
I can check it by calling a site an wait for an exception but it will cost
me time (till the exception will occure)

By using .NET object and methods, how can i check it?

Thanks
 
HI,

Goldwind said:
Hi,

From a desktop application, i want to check if an internet connection
exist.
Many articles use the win api "InternetGetConnectedState", but it is no
sure
thing.
I can check it by calling a site an wait for an exception but it will cost
me time (till the exception will occure)

By using .NET object and methods, how can i check it?

You can't , first what you understand with "having connection to the
internet" , it means different things depending of how the access is done.
For example here in my office I can't use any application that does not work
with a proxy, I cannot connect directly to the internet.

The only reliable way to know if you can do "what you need to access" is
trying it and checking for exception/timeout , etc.
 
Hello Goldwind,

It's a bit ambiguous to check if there is an internet connection or not,
except pinging some server.
All internet resources are like intranet one, it could be or could not be
online sometimes.

What you can be really sure it's if network connection exists.

G> From a desktop application, i want to check if an internet connection
G> exist.
G> Many articles use the win api "InternetGetConnectedState", but it is
G> no sure
G> thing.
G> I can check it by calling a site an wait for an exception but it will
G> cost
G> me time (till the exception will occure)
G> By using .NET object and methods, how can i check it?
G>
G> Thanks
G>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
Thanks, I guess you both are right.

What will be the best way to check for network connection?
 
Hi,



Goldwind said:
Thanks, I guess you both are right.

What will be the best way to check for network connection?

The very same applies. Just try to do what you need to do, and be prepared
to catch an exception or check for errors, if you do get something of the
above, then you have a problem.
 
Back
Top