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: Is there a clean way to get my default IP address.




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:
http://lists.apple.com/mailman/options/macnetworkprog/email@hidden

This email sent to email@hidden
References: 
 >Is there a clean way to get my default IP address. (From: John Draper <email@hidden>)
 >Re: Is there a clean way to get my default IP address. (From: Dalton Hamilton <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.