Re: Multiple IP's of the host machine.
Re: Multiple IP's of the host machine.
- Subject: Re: Multiple IP's of the host machine.
- From: "Peter Sichel" <email@hidden>
- Date: Fri, 3 Mar 2006 09:43:18 -0500
On 3/3/06, innovator information wrote:
>Hello,
>
>How to get multiple IP's of the host machine.
>
>Suppose my machine connects through Airport as well as ethernet.
Presumably you want to determine what these IP addresses are and various
attributes associated with the corresponding interface.
There are two basic approaches:
(1) Use the underlying BSD system calls to enumerate the interfaces on
your system. This is described in "UNIX Network Programming" by W
Richard Stevens. You can use a routing socket for example to list the
interfaces and their "BSD names".
(2) Walk the System Configuration Framework (SCF) to get the current
service order and IP address associated with each network service. This
has the advantage of listing the "service names" that appear in the
Network Preferences Panel. Apple's MoreSCF sample code provides some
guidance for doing this. I haven't looked at the documentation in some
time so hopefully things have improved a bit. Back in the old days the
easiest way to figure this out was to look at raw XML file containing
the system configuration database.
I've used both approaches in my own code. The SCF isn't guaranteed to
contain every interface if the user runs some underlying BSD tool to
configure an interface.
Kind Regards,
- Peter Sichel
Sustainable Softworks
_______________________________________________
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