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-27 09:54:07 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: calista_heart@yahoo.com (Calista) Newsgroups: comp.unix.tru64 Subject: Re: gethostbyname returns only single IP address Date: 27 Apr 2004 09:54:06 -0700 Organization: http://groups.google.com Message-ID: <5d1678ff.0404270854.6abdacbc@posting.google.com> 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> <408D8D8C.3030801@nospam_hp.com> NNTP-Posting-Host: 208.42.8.141 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1083084846 677 127.0.0.1 (27 Apr 2004 16:54:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 27 Apr 2004 16:54:06 +0000 (UTC) Xref: archiver1.google.com comp.unix.tru64:11390 Brian, Here is the info. /etc/hosts file there are entries like this xxx.xx.xx.xx myhostname myhostalias1 yyy.yy.yy.yy myhostname myhostalias2 /* PS: actual ip addrs\hostname are replaced with xxx yyy. etc */ So, I do a gethostbyname(myhostname). It returns only xxx.xx.xx.xx, in other words only the first one listed in /etc/hosts file. I ran your code on Tru64 that also displays only xxx.xx.xx.xx So there must be some configuration option that I am missing. Any ideas on how I can check my DNS configuration? Thanks Brian. Calista. Brian Haley wrote in message news:<408D8D8C.3030801@nospam_hp.com>... > 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); > }