Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting Local IP Address in MacOS X



I am trying to find out how one would get the Local IP address of the
machine without using Open Transport.

I was using OTInetGetInterfaceInfo before to get the list of local IP
addresses.
This question is asked quite frequently on this list. In summary here are the replies:
- Mac OS X is a multihomed system. The computer may have many IP addresses (e.g. the Ethernet and AirPort card both be active and have IP addresses assigned to them).
- An interface may have multiple IP addresses assigned to it (aliases).
- An interface may have multiple IP addresses of different types assigned to it (e.g. IPv4 and IPv6).
- Quinn wrote an excellent Technote on this subject several years ago.
http://developer.apple.com/technotes/tn/tn1145.html
- getifaddrs() is my favorite way to get this information. It will return a list of all interfaces and the IP address assigned to them. If an interface has multiple IPs, it will be returned multiple times. There are other ways to get this information, which Quinn outlines in his technote.


Ryan McGann
email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macnetworkprog/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.