1 /* Based on a test case by grd@algonet.se. */
9 #include <sys/socket.h>
10 #include <netinet/in.h>
11 #include <arpa/inet.h>
17 struct in_addr hostaddr
;
20 inet_aton ("127.0.0.1", (struct in_addr
*) &hostaddr
.s_addr
);
21 ent
= gethostbyaddr (&hostaddr
, sizeof (hostaddr
), AF_INET
);
23 puts ("gethostbyaddr (...) == NULL");
26 puts ("Using gethostbyaddr(..):");
27 printf ("h_name: %s\n", ent
->h_name
);
29 if (ent
->h_aliases
== NULL
)
30 puts ("ent->h_aliases == NULL");
32 printf ("h_aliases[0]: %s\n", ent
->h_aliases
[0]);
35 ent
= gethostbyname ("127.0.0.1");
38 puts ("gethostbyname (\"127.0.0.1\") == NULL");
43 printf ("\nNow using gethostbyname(..):\n");
44 printf ("h_name: %s\n", ent
->h_name
);
45 if (strcmp (ent
->h_name
, "127.0.0.1") != 0)
47 puts ("ent->h_name != \"127.0.0.1\"");
51 if (ent
->h_aliases
== NULL
)
53 puts ("ent->h_aliases == NULL");
58 printf ("h_aliases[0]: %s\n", ent
->h_aliases
[0]);
59 result
|= ent
->h_aliases
[0] != NULL
;