Open System Services System Calls Reference Manual (G06.28+, H06.05+)
gethostbyname_r(2) OSS System Calls Reference Manual
NAME
gethostbyname_r - Gets a host entry by name (reentrant)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <netdb.h>]
#include <spthread.h>
[extern h_errno;]
struct hostent *gethostbyname_r (
const char *name,
struct hostent *host,
char *buffer,
int buflen,
int *h_errnop
);
PARAMETERS
name Specifies the network name or alias.
host Points to a struct hostent structure allocated by the caller.
buffer Points to the buffer supplied by the caller and used as a storage space for host
data.
buflen Specifies the size of the buffer passed in bytes.
h_errnop Points to the global integer h_errno to indicate the error code if an error occurs.
For possible values that might be returned, see the ERRORS subsection of this
reference page.
DESCRIPTION
The gethostbyname_r() function is the reentrant version of the gethostbyname() function.
The gethostbyname_r() function searches host entries sequentially until a match with the name
parameter occurs. This function returns a pointer to a structure of type hostent whose members
specify data obtained from a name server specified in the /etc/resolv.conf file or from fields of a
record line in the /etc/hosts network hostname database file. When the name server is not run-
ning and /etc/resolv.conf cannot be searched, this function searches the /etc/hosts name file.
The gethostbyname_r() function updates the hostent structure pointed to by the host parameter.
Storage referenced by the hostent structure is allocated from the memory provided with the
buffer parameter, which is buflen characters in size. The h_errnop paremeter is updated with the
h_errno value if an error occurs.
NOTES
The netdb.h header file defines the hostent structure.
A return value points to static data, which is overwritten by any subsequent calls to gethost-
byaddr( ), gethostbyaddr_r(), gethostbyname(), gethostbyname_r(), gethostent(),or
gethostent_r().
3−76 Hewlett-Packard Company 527186-007