#include <netdb.h> int gethostent_r(struct hostent *hostent_struct_addr, struct hostent_data *hostent_data_struct_addr)
The gethostent_r() function is used to retrieve information from the host database file. When the gethostent_r() is first called, the file is opened, and the first entry is returned. Each subsequent call of gethostent_r() results in the next entry in the file being returned. To close the file, use endhostent_r().
No authorization is required.
The gethostent_r() function returns an integer. Possible values are:
The struct hostent denoted by hostent_struct_addr and struct hostent_datadenoted by hostent_data_struct_addr are both defined in <netdb.h>. The structure struct hostentis defined as:
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 size of an address in octets (for example, the size of an Internet address is 4 octets). h_addr_list is a pointer to a NULL-terminated list of pointers, each of which points to a network address (in network byte order) for the host.
When the gethostent_r() function fails, errno can be set to:
The hostent_data structure was not properly initialized to hexadecimal zeros before initial use. For corrective action, see the description for structure hostent_data.
Top | UNIX-Type APIs | APIs by category |