It was suggested in an answer here, Get the IP address of the machine, one could use getifaddrs()
to obtain the IP address of the machine the program was running on, which worked great :D:D
However, running the same program on two different systems, one displayed
SERVER_ADDRESS lo 127.0.0.1
SERVER_ADDRESS eth0 129.xxx.xxx.xxx
SERVER_ADDRESS virbr0 192.zzz.zzz.1
while the other displayed
SERVER_ADDRESS lo0 127.0.0.1
SERVER_ADDRESS en0 192.yyy.yyy.yyy
I was going to use strcmp
to differentiate ethernet, but now I realized it doesn't work across systems since different strings may be printed out.
Is there a function (or better way) to check whether or not an ifa_name
is ethernet or not?