gethostby*
Castor Fu
castor at fizzle.stanford.edu
Mon Oct 23 09:18:13 AEST 1989
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 at 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]);
}
}
More information about the Comp.unix.ultrix
mailing list