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?
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?
Alternatively you can also utilize
if_indextoname()
to get available interface names. Here is how Swift implementation would look like:Since iOS works slightly differently to OSX, we had luck using the following code based on Davyd's answer to see the names of all available network interfaces on an iPhone: (also see here for full documentation on ifaddrs)
You can cycle through network interfaces and get their names, IP addresses, etc.
There are many other flags and data in the above structures, I hope you will find what you are looking for.