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 15:31:01 PST Path: archiver1.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!arclight.uoregon.edu!news.infoave.net!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!news.cpqcorp.net!53ab2750!not-for-mail Message-ID: <408D8D8C.3030801@nospam_hp.com> From: Brian Haley User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 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> <5d1678ff.0404261254.5405fb4e@posting.google.com> In-Reply-To: <5d1678ff.0404261254.5405fb4e@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 26 Apr 2004 22:51:12 GMT NNTP-Posting-Host: 16.141.88.143 X-Complaints-To: abuse@HP.com X-Trace: news.cpqcorp.net 1083019872 16.141.88.143 (Mon, 26 Apr 2004 15:51:12 PDT) NNTP-Posting-Date: Mon, 26 Apr 2004 15:51:12 PDT Organization: Hewlett-Packard Company Xref: archiver1.google.com comp.unix.tru64:11387 Calista wrote: > Yes Brian, I have tried the program on Linux, and there it prints both > of the IP addresses. It doesn't print both on Tru64 though. I suspect > the problem is with how the system is configured, but I have no idea > where\what to look for. You still haven't given enough configuration information - do the two IP addresses have different hostnames associated with them? I would not expect that to return more than one address unless there is some special DNS configuration. Just so we're on the same page, I've included an example gethostbyname() utility I use. # ./gethostbyname `hostname` Oh, and my Linux box behaves like Tru64 :) -Brian #include #include #include void printhostent(); void print_h_errno(); main ( argc, argv ) int argc; char *argv[]; { struct hostent *hp; if ( argc != 2 ) printf("Usage: gethostbyname host\n"); else if ( hp = gethostbyname(argv[1]) ) { printf("hp = 0x%lx\n", hp); printhostent(hp); } else print_h_errno(); } void printhostent ( hp ) struct hostent *hp; { char **cpp; struct in_addr addr; printf("struct hostent:\n"); printf("\t h_name %s\n",hp->h_name); cpp = hp->h_aliases; if ( !*cpp ) printf("\t h_aliases\n"); else { printf("\t h_aliases %s\n",*cpp); while ( *++cpp ) printf("\t %s\n",*cpp); } printf("\t h_addrtype %d\n",hp->h_addrtype); /*** CONVERT TO MNEMONIC ***/ printf("\t h_length %d\n",hp->h_length); cpp = hp->h_addr_list; if ( !*cpp ) printf("\t h_addr_list\n"); else { addr.s_addr = **(u_int **)cpp; printf("\t h_addr_list %s\n",inet_ntoa(addr)); while ( *++cpp ) { addr.s_addr = **(u_int **)cpp; printf("\t %s\n",inet_ntoa(addr)); } } } void print_h_errno() { char *msg; switch(h_errno) { case HOST_NOT_FOUND: msg = "HOST_NOT_FOUND"; break; case TRY_AGAIN: msg = "TRY_AGAIN"; break; case NO_RECOVERY: msg = "NO_RECOVERY"; break; case NO_ADDRESS: msg = "NO_ADDRESS"; break; default: msg = "unknown error code"; } printf("h_errno: %s\n",msg); }