Network Status Change Event Capture

I try to receive events when the Internet connection is restored after it is lost. This is the data transfer software that I am developing. If I lose the network during data transfer, I would like to receive a notification when it returns and continue the transfer automatically.

I can, of course, create a separate thread and check the network once in a while using a timer, but maybe there is a better option.

I develop for Windows mainly in C ++ (not .net).

I can also use wxwidgets (I use it for the GUI), but I doubt that it offers any related features.

+3
source share
3 answers

You might want to check out the System Event API (SENS) http://msdn.microsoft.com/en-us/library/cc185680(VS.85).aspx

I have not actually used it, but it looks like it delivers the events you are looking for.

EDIT:

WMI has all the necessary information about various network connections and state changes. It also has an asynchronous event model that can be used to receive notifications. The trick, I suppose, is generating the correct WMI request to get the required information. This blog looks like the right type of request, and this MSDN explains how to handle events asynchronously.

+2
source

, , , . , , .

0

Source: https://habr.com/ru/post/1729219/


All Articles