Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

OSS Library Calls (g - h) gethostbyname(3)
NAME
gethostbyname - Gets a host entry by name
LIBRARY
G-series native OSS processes: /G/system/sysnn/zinetsrl
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zinetdll |
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/yinetdll |
SYNOPSIS
#include <netdb.h>
extern int h_errno;
struct hostent *gethostbyname(
const char *name);
PARAMETERS
name Specifies the network name or alias.
DESCRIPTION
The gethostbyname( ) function searches host entries sequentially until a match with the name
parameter occurs.
The gethostbyname( ) 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 can not be searched, this function searches the /etc/hosts name file. The
netdb.h header file defines the hostent structure.
NOTES
For gethostbyname( ), a return value points to static data, which is overwritten by any subse-
quent calls to gethostbyaddr( ), gethostbyname( ),orgethostent( ).
RETURN VALUES
Upon successful completion, gethostbyname( ) returns a pointer to a hostent structure if the
entry was found, and a null pointer if the entry was not found. If the call to gethostbyname( )
fails, a null pointer is returned.
ERRORS
If any of the following conditions occurs, the gethostbyname( ) 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.
TRY_AGAIN An error occurred that might have been caused by a transient condition. A retry
at some later time might be successful.
NO_RECOVERY
This is a nonrecoverable error.
NO_DATA The requested name is valid but no associated address was found. Another type
of name server request might succeed.
527187-017 Hewlett-Packard Company 359