From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,b308574f9841b3bf X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2004-04-23 13:24:13 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!HSNX.atgi.net!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!news.cpqcorp.net!53ab2750!not-for-mail Sender: Rick Jones From: Rick Jones Subject: Re: gethostbyname returns only single IP address Newsgroups: comp.unix.tru64 References: <5d1678ff.0404220743.37a2d7e1@posting.google.com> Organization: the Unofficial HP User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (HP-UX/B.11.00 (9000/785)) Message-ID: Date: Fri, 23 Apr 2004 20:43:28 GMT NNTP-Posting-Host: 15.244.44.58 X-Complaints-To: abuse@HP.com X-Trace: news.cpqcorp.net 1082753008 15.244.44.58 (Fri, 23 Apr 2004 13:43:28 PDT) NNTP-Posting-Date: Fri, 23 Apr 2004 13:43:28 PDT Xref: archiver1.google.com comp.unix.tru64:11382 Calista wrote: > I use gethostbyname() to get all the IP addresses on my machine. But > it only returns the first one in /etc/hosts file. > Should I do anything different? I thought that when name resolution was accomplished via /etc/hosts only one address was returned and it was only with DNS or whatnot that one would get multiple IPs. At least under HP-UX, the manpage for gethostbyname reads (in part): Nonserver Operation If the /etc/hosts file is used for name or address resolution, then the function: gethostent() Reads the next line of /etc/hosts, opening the file if necessary. sethostent() Opens and rewinds the file. If the stayopen flag is non-zero, the host data base is not closed after each call to gethostent() (either directly or indirectly through one of the other gethost calls). endhostent() Closes the file. gethostbyname() Sequentially searches from the beginning of the file until a host name (among either the official names or the aliases) matching its name parameter is found, or until EOF is encountered. Names are matched without respect to uppercase or lowercase, as described above in the name server case. gethostbyaddr() Sequentially searches from the beginning of the file until an Internet address matching its addr parameter is found, or until EOF is encountered. Which suggests that gethostbyname() stops after the first match. Now, whether the Tru64 manpage says the same I don't know. rick jones -- Wisdom Teeth are impacted, people are affected by the effects of events. these opinions are mine, all mine; HP might not want them anyway... :) feel free to post, OR email to raj in cup.hp.com but NOT BOTH...