How do I get the currently connected network interface name using Cocoa or Foundation?
问题 I need to know the network interface name of the currently connected network interface, as in en0 , lo0 and so on. Is there a Cocoa/Foundation function that is going to give me this information? 回答1: You can cycle through network interfaces and get their names, IP addresses, etc. #include <ifaddrs.h> // you may need to include other headers struct ifaddrs* interfaces = NULL; struct ifaddrs* temp_addr = NULL; // retrieve the current interfaces - returns 0 on success NSInteger success =