• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting the private IP
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the private IP


  • Subject: Re: Getting the private IP
  • From: "Mr. Gecko" <email@hidden>
  • Date: Fri, 8 May 2009 18:36:21 -0500

I'm writing a personal application for managing my domains, and I think what I wrote will work well enough for me. But the problem where if it's a self-assigned address does miss with my setup. Because sometimes I'll hock it up via firewire to my server for fast backup.

On May 8, 2009, at 6:32 PM, Alastair Houghton wrote:

On 8 May 2009, at 15:46, Mr. Gecko wrote:

Hello, I'm trying to find out how to get the private IP address.
This is my quick way of finding out.
- (NSString *)localIP {
	NSString *IPAddress = @"";
	struct ifaddrs *myaddrs, *ifa;
	struct sockaddr_in *s4;
	int status;
	char buf[64];

	status = getifaddrs(&myaddrs);

[snip]

is there a better way?

Depends what you are trying to achieve. It might be better if you could explain what you are doing that needs this information, since there are some alternatives that might be better in some cases.


Additionally, you need to be careful because:

- There may be more than one active interface with an IP address
- There may be more than one IP address for each active interface
- Your idea of the right interface to use might not match the user's idea (or the system's idea)


Unless you're doing some very low-level networking code, you can usually live without knowing "the" IP address of the system (to the extent that such a thing actually exists).

Kind regards,

Alastair.

--
http://alastairs-place.net




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Getting the private IP (From: "Mr. Gecko" <email@hidden>)
 >Re: Getting the private IP (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: Getting the private IP
  • Next by Date: converting a characer to a keycode
  • Previous by thread: Re: Getting the private IP
  • Next by thread: Re: Cocoa-dev Digest, Vol 6, Issue 702
  • Index(es):
    • Date
    • Thread