Open System Services Library Calls Reference Manual (G06.28+, H06.05+)

OSS Library Calls (g - h) gethostbyname2(3)
NAME
gethostbyname2 - Gets an Internet host entry by name and IPv4 or IPv6 address family
LIBRARY
G-series native OSS processes: /G/system/sysnn/zinetsrl
H-series OSS processes: /G/system/zdllnnn/zinetdll
SYNOPSIS
#include <netdb.h>
extern h_errno;
struct hostent *gethostbyname2 (
const char *name,
int af);
PARAMETERS
name Points to either the ofcial name or an alias of the host whose Internet address is
to be found.
af Species the address family searched for and returned by the function. Valid
values are AF_INET (IPv4) or AF_INET6 (IPv6).
DESCRIPTION
The gethostbyname2() function searches host entries sequentially until a match with the value
pointed to by the name parameter occurs.
The gethostbyname2() function returns a pointer to a structure of type hostent whose members
specify data obtained from a name server specied in the /etc/resolv.conf le or from elds of a
record line in the /etc/hosts network hostname database le. (When the name server is not run-
ning and /etc/resolv.conf cannot be searched, this function searches the /etc/hosts name le.)
The <netdb.h> header le denes the hostent structure.
NOTES
The name value passed to the gethostbyname2() function is case-sensitive.
The hostent structure is statically declared. Subsequent calls to gethostbyname2() replace the
existing data in the hostent structure.
RETURN VALUES
Upon successful completion, gethostbyname2() returns a pointer to a structure (based on the
hostent structure) in which information on the specied host is returned. The information
includes the ofcial name, aliases, and addresses for the host.
If the call to gethostbyname2() fails, a null pointer is returned.
ERRORS
If any of the following conditions occurs, the gethostbyname2() function sets h_errno to the
value that corresponds to the condition:
HOST_NOT_FOUND
The name you have used is not a valid hostname or alias. This is not a soft error;
another type of name server request might be successful.
This is the only possible value if the resolver code has been disabled.
TRY_AGAIN The local server did not receive a response from an authoritative server. A retry
at a later time might succeed.
527187-007 Hewlett-Packard Company 335