• 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: Problem in getting local IP through
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem in getting local IP through


  • Subject: Re: Problem in getting local IP through
  • From: "Justin C. Walker" <email@hidden>
  • Date: Tue, 24 Jun 2003 22:31:16 -0700

On Tuesday, June 24, 2003, at 09:51 PM, Pranav Kumar Sahu wrote:

Actually i am using "gethostbyname()" to get the hostent and then I am
converting it to a in_addr. Where I have the problem with the IP Address.
Since it returns proper IP Address in some systems and "127.0.0.1" in few
system, I feel I need to configure some network setting.

"127.0.0.1" is a proper IP address. As Josh indicated, you are getting a *list* of addresses, and you have to look at each in the list (h_addr_list).

The problem you are having may be that you want a single IP address, and there really is no such thing in today's IP world. Each system can have multiple active interfaces (e.g., "lo0" for loopback; the built-in ethernet adapter; and an airport/wireless adapter); and each interface can have multiple valid IP addresses, some of which will have global scope, and some of which won't (the latter can be RFC 1918 "private" addresses, or "zero-conf/link-local" addresses). This situation will only "improve" as IPv6 gains currency, so developers need to learn to deal with it.

Since there will be (potentially) many IP addresses assigned to your host, trying to specify "the" IP address is not going to work well. Looking at Quinn's opus on this subject (TN1145 - Living in a Dynamic TCP/IP Environment) may help.

In your case, it appears that the given host name is set up to refer both to the loopback address (127.0.0.1) and another address, but it's hard to tell without more details. What are you trying to achieve?

Regards,

Justin

--
/~\ The ASCII Justin C. Walker, Curmudgeon-at-Large
\ / Ribbon Campaign
X Help cure HTML Email
/ \
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

References: 
 >RE: Problem in getting local IP through (From: Pranav Kumar Sahu <email@hidden>)

  • Prev by Date: RE: Problem in getting local IP through
  • Next by Date: bootp example
  • Previous by thread: RE: Problem in getting local IP through
  • Next by thread: bootp example
  • Index(es):
    • Date
    • Thread