Mac-os-x how to get network details like ip-address, subnet mask,etc
I a开发者_JAVA百科m new to Mac-OS-X development. I want to get the users Network details just for displaying it in my application. Details such as the IP address, Subnet mask, status whether connected or not, etc.
Is it possible to get the same??
And secondly, Is the IP address different for wireless lan connections and the normal ethernet connections?? I am a little weak at networking concepts.
Any help will be appreciated.
note: I already tried searching the apple developer site for leads but wat i could find is only the System Configuration Programming guide
Strange.. There are no Frameworks or classes to get the IP address... But i somehow managed to get my hands on the following information.. First with this reference.. And secondly i found that..
- As mentioned in the link, If we manually set the IP, then it gets stored in the
preferences.plist
. But if we set the IP to DCHP, then we can get the ConfigMethod as "DCHP" and hence check the
com.apple.network.identification.plist
, it'll have the details for the IP address.Hence with the use of both the plist and checking whether the ConfigMethod is "Manual" or "DCHP" we can get the current IP address albeit this is not documented anywhere.
精彩评论