[comp.unix.ultrix] gethostby*

castor@fizzle.stanford.edu (Castor Fu) (10/23/89)

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 <netdb.h>
#include <sys/socket.h>

#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]);
  }
}