Nov 19, 2011
This is the work of one responder for the most part, and is not indicative of the quality of most of the posts.But you can judge that for yourself.
View 1 Replies
If you are writing a program that is used to monitor the status of your network, then this thread may not be of interest.
If you are an application programmer that uses network resources to accomplish your goal, i.e. you are using SMTP, FTP, HTTP, NNTP, NTP etc., and you think that you need to check for a connection first, then read on.Follow up to this.Before getting all geeky let's take a little detour...
Five days a week I get up, eat breakfast, check my email, forums, etc., take a shower, get dressed, and then drive to school.Many of you probably have a similar routine.What is interesting about that is not what we do, but what we dont do,because of our expectations and experience.Here is what I dont do.
I dont stick my finger in the electrical socket to see if there is electricity for the coffee maker and toaster.I dont fire up the command prompt and ping some host on the internet to see if I have connectivity.I dont check the battery, tires, water level, clutch fluid level, washer fluid level, etc.,before I drive off.
All of that is based on expectation and experience.So why would you write an application that pings the internet before it did something (SMTP, FTP, HTTP, NNTP, NTP etc)???? Is your experience or expectation that the network will be down?To illustrate and hopefully convince you that, like Oblio, it is pointless, create a new form with three buttons. In the following examples I use a WebRequest / WebResponse as my 'Something'.Here is what some think is a good approach, the classic ping-then-do, what I think you shouldn't do.[code]....What is wrong with this code is that all of the network IO is being done without a Try / Catch block.