|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
testing internet connectin>From a C# windows app, how can I easily tell if I have a connection to Thanks,the internet. Rick Easiest way is to try connect somewhere and catch exception if needed.
Hello, Rick!
You can try to connect to a well known internet resource. try { TcpClient tcpClient = new TcpClient (); tcpClient.Connect ("www.microsoft.com", 80); //connection is available } catch(SocketException ex) { //smth is wrong - maybe there is no connection } The approach above is rather straightforward, can you tell why do you have to know if you're connected to the Internet. I prefer not to have to catch exceptions, but this will work.
(I am retrieving information from the web or a local cache if not connected.) Thanks, Rick
AppDomains and Exceptions
String concatenation -- not the typical question How properly return XML from an ASPX page? cannot implicitly convert type string to bool Converting a float to a string How to detect a null value Scope and values of Object XML Schmell !!! Why can't my delegate be public? How to tell when a form is minimizing or closing! |
|||||||||||||||||||||||