I am trying to find which network interfaces (of the local machine which has multiple IPs) are up and which are down. Is there a C/C++ function for this? Thanks!
Asked
Active
Viewed 1,087 times
3 Answers
2
See the getifaddrs man page. You can find code and man page here.

Manjunath N
- 1,365
- 11
- 22

saurabh agarwal
- 2,124
- 4
- 24
- 46
-
It gives all the interface details. Not just the ones which are up. – aniztar Jan 08 '15 at 11:46
-
1You can check Tx and Rx packets. – saurabh agarwal Jan 08 '15 at 19:18
0
Use /proc/net/
see proc(5) for more. And also /sys/class/net/

Basile Starynkevitch
- 223,805
- 18
- 296
- 547
0
you can use GETIFADDRS(3) function creates a linked list of structures describing the network interfaces of the local system, and stores the address of the first item of the list in *ifap.
after getting all the IPs you can use ping to check whether IP is up or down
if ( system("ping x.x.x.x ") == 0)
{
doSomthing();
}

rabi shaw
- 441
- 1
- 3
- 14