Observing network change event in linux application

57 views Asked by At

I have an application where I wanted to get notified if there is any network change that has occured. I have found a bunch of solution like

  • using NetworkManager or systemd-network service (which I do not prefer because I do not know If these services are installed and running on the users system or not)
  • using Netlink socket : Here all the network change event information is queued in the netlink message queue, and a handler in our application will fetch the data from this queue and process it. We have to use a while(1) loop, which periodically processes data from this queue. (This approach requires to constantly poll for any updates from the queue)

Other platforms like windows and mac have observer APIs where we can subscribe for the network change event and our application gets notified in a handler whenever this event takes place. I m looking if something similar in available in linux?

0

There are 0 answers