gethostbyaddr_r

Name

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

Synopsis

#include <netdb.h>

int gethostbyaddr_r(const void * restrict addr, socklen_t len, int type, struct hostent * restrict result_buf, char * restrict buf, size_t buflen, struct hostent * * restrict result, int * h_errnop);

Description

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

gethostbyaddr_r() is a reentrant version of gethostbyaddr() that searches the network host database for a host address match.

The gethostbyaddr_r() function shall search the network host database for an entry of address family type with the host with address addr. The len argument contains the length of the address referenced by addr.

If type is AF_INET, the addr argument shall be an in_addr structure. If type is AF_INET6, the addr argument shall be an in6_addr structure. If type is any other value, the behavior is unspecified.

The application must provide a buffer for the gethostbyaddr_r() 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, gethostbyaddr_r() may fail and return ERANGE. If a matching entry is found in the database, gethostbyaddr_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 gethostbyaddr_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 gethostbyaddr_r() function returns returns any other value, then the variable referenced by h_errnop shall be set to indicate the cause as for gethostbyaddr().