Depending on the operating system, I don't know.
But my first guess is no, there's no notification when the network cable is unplugged, you need to check that yourself.
Maybe on linux using hal (or its replacement)/dbus/... there might be a way to get a notification.
On Windows, check MSDN for System Notification Services.
You can also try to play with the keep alive option of the socket.
A socket is closed when you explicitly close it. Unplugging the network cable unfortunatly doesn't close the connection, it will just time out. By setting the keep alive value very low, you can minimize the time out. However, this might come with more problems than solutions.
Constantly checkking the status of the network isn't a problem though. It is a correct thing to do. Certainly when you know that the OS, other libraries, ... will most likely do the same but make you add more complexity to your program.
What are your biggest problems with this technique?
Bookmarks