Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!brutus.cs.uiuc.edu!apple!agate!shelby!portia!portia.stanford.edu!castor From: castor@fizzle.stanford.edu (Castor Fu) Newsgroups: comp.unix.ultrix Subject: gethostby* Message-ID: Date: 22 Oct 89 23:18:13 GMT Sender: USENET News System Organization: Physics Dept., Stanford University Lines: 34 I have the following problem with a DECstation 3100 running ultrix 3.1/2.1. When I try the program below, I am incapable of locating any of my aliases listed in my /etc/hosts file, the program simply returns the full name, without any aliases. Is this behavior correct? Castor Fu castor@fizzle.stanford.edu #include #include #define NULL 0 main() { struct hostent *myhost; char addr[4]; int i; myhost=gethostbyname("fizzle.stanford.edu"); printf("h_name ::%s::\n",myhost->h_name); for (i=0; myhost->h_aliases[i] != NULL; i++) { printf("h_aliase[%d] ::%s::\n",i,myhost->h_aliases[i]); } addr[0] = 36; addr[1] = 92; addr[2] = 0 ; addr[3] = 200; myhost=gethostbyaddr(addr,4,AF_INET); printf("h_name ::%s::\n",myhost->h_name); for (i=0; myhost->h_aliases[i] != NULL; i++) { printf("h_aliase[%d] ::%s::\n",i,myhost->h_aliases[i]); } }