Re: Is there a clean way to get my default IP address.
Re: Is there a clean way to get my default IP address.
- Subject: Re: Is there a clean way to get my default IP address.
- From: "Justin C. Walker" <email@hidden>
- Date: Tue, 6 Dec 2005 00:23:56 -0800
On Dec 5, 2005, at 23:50 , Dalton Hamilton wrote:
Her is a small c routing that will give you your IP address. Of
course, there are multiple interfaces on a system and this example
will grab the en0 IP address. As I'm sure you are aware, "netstat -
in" will give you a list of interface names.
The problem, as suggested in TN1145 (pointed out by Rustam earlier),
is that on a system like Mac OS X, the OP's goal isn't really
achievable. There is nothing that qualifies as "the" or "my" IP
address on a Mac OS X system.
The best you can hope for is to determine the default interface
(using the SystemConfiguration framework), and select, more or less
at random, one address on that interface.
TN1145 should be really be required reading :-}.
Cheers,
Justin
--
Justin C. Walker, Curmudgeon-at-Large
() The ASCII Ribbon Campaign
/\ Help Cure HTML Email
_______________________________________________
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