gethostent.3n (2010 09)

g
gethostent(3N) gethostent(3N)
NAME
gethostent(), gethostbyaddr(), gethostbyname(), sethostent(), endhostent() - get, set, or end network host
entry
SYNOPSIS
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
struct hostent *gethostent(void);
struct hostent *gethostbyname(const char *name);
struct hostent *gethostbyaddr(const char *addr,
int len,
int type);
_XOPEN_SOURCE_EXTENDED only
struct hostent *gethostbyaddr(const void *addr,
size_t len,
int type);
int sethostent(int stayopen);
int endhostent(void);
_XOPEN_SOURCE_EXTENDED only
void sethostent(int stayopen);
void endhostent(void);
DESCRIPTION
The gethostent(), gethostbyname()
, and gethostbyaddr() functions each return a pointer to
a structure of type
hostent, defined as follows in <netdb.h>:
struct hostent {
char *h_name;
char **h_aliases;
int h_addrtype;
int h_length;
char **h_addr_list;
};
#define h_addr h_addr_list[0]
The members of this structure are:
h_name The ofcial name of the host.
h_aliases A null-terminated array of alternate names for the host.
h_addrtype The type of address being returned; always AF_INET.
h_length The length, in bytes, of the address.
h_addr_list A null-terminated array of network addresses for the host.
h_addr The first address in h_addr_list; this is for compatibility with previous
HP-UX implementations where a struct hostent contains only one net-
work address per host.
Name Service Switch-Based Operation
These host entry library routines internally call the name service switch to access the "hosts" database
lookup policy configured in the
/etc/nsswitch.conf file (see nsswitch.conf(4)). The lookup policy
defines the order and the criteria of the supported name services used to resolve host names and Internet
addresses. The operations of these name services: Domain Name Server, NIS, and nonserver mode (e.g.,
files) are listed below.
Domain Name Server Operation
If the local system is configured to use the
named name server (see named(1M) and resolver (4)) for name
or address resolution, then the function:
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (6 pages)