gethostbyname2_r

Name

gethostbyname2_r -- find network host database entry matching host name (DEPRECATED)

Synopsis

int gethostbyname2_r(const char * restrict name, int af, struct hostent * restrict result_buf, char * restrict buf, size_t buflen, struct hostent ** restrict result, int * restrict h_errnop);

Description

Note: The gethostbyname2_r() function is deprecated; applications should use getaddrinfo() instead.

The gethostbyname2_r() function shall search the network host database for an entry with name name. gethostbyname2_r() is a reentrant version of gethostbyname2(). These functions are similar to the gethostbyname() and gethostbyname_r() functions but additionally allow the search to be restricted to a particular address family specified by af.

The application must provide a buffer for the gethostbyname2_r() function to use during the lookup process. The buffer is referenced by buf, and is of size buflen. If the buffer is not of sufficient size, gethostbyname_r() may fail and return ERANGE. If a matching entry is found in the database, gethostbyname_r() shall copy the relevant information to the application-supplied hostent structure referenced by result_buf, and return a pointer to this structure in *result. If no matching entry is found, *result shall be set to a null pointer. Additional error information shall be set in the variable referenced by h_errnop.

Return Value

On success, the gethostbyname2_r() function shall return zero. If the return value was ERANGE, the size of the buffer buf, indicated by buflen, was too small. If the gethostbyname2_r() function returns returns any other value, then the variable referenced by h_errnop shall be set to indicate the cause as for gethostbyname_r().