Re: Getting Local IP Address in MacOS X
Re: Getting Local IP Address in MacOS X
- Subject: Re: Getting Local IP Address in MacOS X
- From: Ryan McGann <email@hidden>
- Date: Sat, 17 Sep 2005 12:19:56 -0700
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:
This email sent to email@hidden