#include <netdb.h> struct hostent *gethostent()
The gethostent() function is used to retrieve information from the host database file. When gethostent() is first called, the file is opened, and the first entry is returned. Each subsequent call to gethostent() results in the next entry in the file being returned. To close the file, use endhostent().
No authorization is required.
gethostent() returns a pointer. Possible values are:
The structure struct hostent is defined in <netdb.h>.
struct hostent {
char *h_name;
char **h_aliases;
int h_addrtype;
int h_length;
char **h_addr_list;
};
#define h_addr h_addr_list[0]
h_name points to the character string that contains the name of the host. h_aliases is a pointer to a NULL-terminated list of pointers, each of which points to a character string that represents an alternative name for the host. h_addrtype contains the address type of the host (for example, AF_INET). h_length contains the address length. h_addr_list is a pointer to a NULL-terminated list of pointers, each of which points to a network address for the host, in network byte order. Note that the array of address pointers points to structures of type in_addr defined in <netinet/in.h>.
| Top | UNIX-Type APIs | APIs by category |