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-26 06:44:56 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!news.cpqcorp.net!53ab2750!not-for-mail From: Brian Haley User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7b) Gecko/20040421 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.unix.tru64 Subject: Re: gethostbyname returns only single IP address References: <5d1678ff.0404220743.37a2d7e1@posting.google.com> <2as96c.7gf.ln@dadsys2.fuller.local> <5d1678ff.0404230504.2eb35ac4@posting.google.com> In-Reply-To: <5d1678ff.0404230504.2eb35ac4@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Mon, 26 Apr 2004 14:05:00 GMT NNTP-Posting-Host: 16.115.201.205 X-Complaints-To: abuse@HP.com X-Trace: news.cpqcorp.net 1082988300 16.115.201.205 (Mon, 26 Apr 2004 07:05:00 PDT) NNTP-Posting-Date: Mon, 26 Apr 2004 07:05:00 PDT Organization: Hewlett-Packard Company Xref: archiver1.google.com comp.unix.tru64:11385 I'm not sure gethostbyname() will return what you're looking for. You said the system has two interfaces with two IP addresses, I'm assuming each has a name associated with it, for example: 10.0.0.1 foo # address on ee0 11.0.0.1 bar # address on ee1 If I do a gethostbyname("foo") I would only expect to get one IP address back - the one for foo, the address for bar would not be returned. The preferred way to get all the local IP address information is to use ioctl(SIOCGIFCONF, ...). Have you tried this on a similarly configured system running a different OS, maybe Linux? Or a different Tru64 version? Is the behavior the same? -Brian Calista wrote: > hostname is passed to this function. > > if ((hp = gethostbyname(hostname)) <= (struct hostent *)0 > return -1; > > for( i = 0; i < 4; i++ ) { /* I can have max 4 ip addresses */ > if( hp->h_addr_list[i] == NULL ) > break; > memzero (&sin, sizeof(sin)); > memcpy (hp->h_addr_list[i], &sin.sin_addr, hp->h_length); > sin.sin_family = hp->h_addrtype; > /* Get IP address. */ > strncpy( ipaddress[i], inet_ntoa(sin.sin_addr), length ); > /* take care of NULL character at end in ipaddress[i] */ > } > > Now I print all IP addresses. It prints only one IP address although my > machine has multiple interfaces (two ip addresses). > > Let me know if you need more info. > > Calista.