The gethostbyaddr() call tries to resolve the IP address
to a host name. The resolution attempted depends on how the resolver
is configured and if any local host tables exist. If the symbol RESOLVE_VIA_LOOKUP
is defined before including MANIFEST.H, gethostbyaddr() only uses
local host tables and name servers are not used. See z/OS Communications Server: IP Configuration
Guide for information about configuring the resolver
and using local host tables.
#include <manifest.h>
#include <netdb.h>
struct hostent *gethostbyaddr(char *addr, int addrlen, int domain)
- Parameter
- Description
- addr
- Points to an unsigned long value containing the address of the
host
- addrlen
- Size of addr in bytes
- domain
- Address domain supported (AF_INET)
The gethostbyaddr() call points to hostent structure for the host address specified on
the call.
The NETDB.H header file defines the
hostent structure, and contains the following elements:
- Element
- Description
- h_name
- The address of the official name of the host
- h_aliases
- A pointer to a zero-terminated list of addresses pointing to alternate
names for the host
- h_addrtype
- The type of host address returned; currently, always set to AF_INET
- h_length
- The length of the host address, in bytes
- h_addr
- A pointer to a zero-terminated list of addresses pointing to the
internet host addresses returned by the call
Return values
The return value points to
static data that is overwritten by subsequent calls. A pointer to a
hostent structure indicates success. A NULL pointer indicates an
error or end-of-file. When a NULL pointer or 0 is returned, the value
of errno is indeterminate: the output from a tcperror() call cannot
be validated. The global variable h_errno identifies the specific
error.
- h_errno
- Description
- HOST_NOT_FOUND
- The name specified is unknown, the address domain specified is
not supported, or the address length specified is not valid.
- TRY_AGAIN
- Temporary error; information not currently accessible.
- NO_RECOVERY
- Fatal error occurred.
Related calls
gethostent(), sethostent(),
endhostent()