detecting connected interface using c++ in linux
c++, linux, networking, routes, tcp
Solution
If you are using NetworkManager, you can use it's API. You can either use the D-Bus API, the GLib wrapping, C++ Bindings for D-Bus.
If you are using Qt, you can directly use QtNetwork.
Of course, you can also go very low-level and use `ioctl(7)`. See lsif by Adam Risi for an example.
Problem
I want to detect which interface is now connected; and I have three 3g-modem connections and two lan connections to the server(my device didn't support wlan). I mean the type of connection is not important but the interface name and specifics is what important for me. I want to detect connected interface in my program that I wrote in c++. please tell me how to detect connected interface in c++?(root permission is not a problem.)