The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Checking network interface

The client application that I write has a feature to check for the network connection and let the user know if it is lost.
A very logical way to implement it is to write a ping thread that constantly pings the server. If the pinged packets never returned, then let the user know. I cannot do this for multiple reasons, a) I don't know where the server is (it is a multicast communication) b) that is a security breach.

How would you implement this ?
Tony Send private email
Thursday, April 05, 2007
You have not specified your language and platform. I am assuming you are on Windows.

You can:

1. Simplest way first: ping a known host, say,

2. Read the registry. I found the place once and have forgotten it again. I'll just search and repost the exact place in the registry.

3. use wininet.dll's InternetGetConnectedState().

4. use sensapi.dll's IsNetworkAlive()
Sathyaish Chakravarthy Send private email
Thursday, April 05, 2007
Unfortunately, I can't seem to find the registry hive precisely now. I was once idling around and found it. It is something like "Internet Settings" or "Proxies" or something.

Sorry for not remembering that.
Sathyaish Chakravarthy Send private email
Thursday, April 05, 2007
You have two conflicting requirements.

If it's a security breach to connect to another machine, then you cannot verify the connection exists by sending pings, packets, or anything else requiring such a connection.

I think given constraint A, you should send a warning message whenever the number of packets you receive drop below a certain threshold. For example, if you've received nothing in the past 15 minutes, you'll send a message to the user saying "We haven't seen any traffic in 15 minutes. Verify that your cable is plugged in, and the other machines still exist."
Thursday, April 05, 2007
Can't you try multicasting your own UDP packet and if it's not sent after some timeout, there's a problem?
Thursday, April 05, 2007
I didn't know UDP could do that. My understanding is that I could physically cut the cable and as far as the sending computer was concerned, the packets would be sent and ergo, the network is alive. TCP in contrast requires an acknowlegement from the destination.

Am I wrong?
Thursday, April 05, 2007
WMI would give you network status by delegating on Windows
Friday, April 06, 2007

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz