#include <netdb.h>
netdb.h
macro_PATH_HEQUIV
#define _PATH_HEQUIV "/etc/hosts.equiv"
macro_PATH_HOSTS
#define _PATH_HOSTS "/etc/hosts"
macro_PATH_NETWORKS
#define _PATH_NETWORKS "/etc/networks"
macro_PATH_PROTOCOLS
#define _PATH_PROTOCOLS "/etc/protocols"
macro_PATH_SERVICES
#define _PATH_SERVICES "/etc/services"
variableh_errno
extern int h_errno
structhostent
Structures returned by network data base library. All addresses are
supplied in host order, and returned in network order (suitable for
use in system calls).
| char * | h_name | official name of host |
| char ** | h_aliases | alias list |
| int | h_addrtype | host address type |
| int | h_length | length of address |
| char ** | h_addr_list | list of addresses from name server |
structnetent
Assumption here is that a network number
fits in an unsigned long -- probably a poor one.
| char * | n_name | official name of net |
| char ** | n_aliases | alias list |
| int | n_addrtype | net address type |
| uint32_t | n_net | network # |
structservent
| char * | s_name | official service name |
| char ** | s_aliases | alias list |
| int | s_port | port # |
| char * | s_proto | protocol to use |
structprotoent
| char * | p_name | official protocol name |
| char ** | p_aliases | alias list |
| int | p_proto | protocol # |
structaddrinfo
| int | ai_flags | AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST |
| int | ai_family | PF_xxx |
| int | ai_socktype | SOCK_xxx |
| int | ai_protocol | 0 or IPPROTO_xxx for IPv4 and IPv6 |
| socklen_t | ai_addrlen | length of ai_addr |
| char * | ai_canonname | canonical name for hostname |
| struct sockaddr * | ai_addr | binary address |
| struct addrinfo * | ai_next | next structure in linked list |
structrpcent
| char * | r_name | name of server for this rpc program |
| char ** | r_aliases | alias list |
| int | r_number | rpc program number |
macroNETDB_INTERNAL
Error return codes from gethostbyname() and gethostbyaddr()
(left in h_errno).
#define NETDB_INTERNAL -1
see errno
macroEAI_ADDRFAMILY
Error return codes from getaddrinfo()
#define EAI_ADDRFAMILY 1
address family for hostname not supported
macroEAI_MAX
#define EAI_MAX 15
macroAI_MASK
valid flags for addrinfo (not a standard def, apps should not use it)
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG)
macroAI_DEFAULT
special recommended flags for getipnodebyname
#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
macroAI_UNUSABLE
If the hints pointer is null or ai_flags is zero, getaddrinfo() automatically defaults to the AI_DEFAULT behavior.
To override this default behavior, thereby causing unusable addresses to be included in the results, pass any nonzero
value for ai_flags, by setting any desired flag values, or by setting AI_UNUSABLE if no other flags are desired.
#define AI_UNUSABLE 0x10000000
return addresses even if unusable (i.e. opposite of AI_DEFAULT)
macroNI_MAXSERV
#define NI_MAXSERV 32
macroNI_NUMERICHOST
#define NI_NUMERICHOST 0x00000002
macroNI_NAMEREQD
#define NI_NAMEREQD 0x00000004
macroNI_NUMERICSERV
#define NI_NUMERICSERV 0x00000008
macroNI_NUMERICSCOPE
#define NI_NUMERICSCOPE 0x00000100
macroNI_DGRAM
#define NI_DGRAM 0x00000010
macroNI_WITHSCOPEID
#define NI_WITHSCOPEID 0x00000020
functionendhostent
void endhostent(void)
man page · May 12, 2006
endhostent(3) — get network host entryfunctionfreeaddrinfo
void freeaddrinfo(struct addrinfo *)
man page · July 1, 2008
freeaddrinfo(3) — socket address structure to host and service namefunctiongai_strerror
const char *gai_strerror(int)
man page · May 21, 2006
gai_strerror(3) — get error message string from EAI_xxx error codefunctiongetaddrinfo
int getaddrinfo( const char * __restrict, const char * __restrict, const struct addrinfo * __restrict, struct addrinfo ** __restrict )
man page · July 1, 2008
getaddrinfo(3) — socket address structure to host and service namefunctiongethostbyaddr
struct hostent *gethostbyaddr(const void *, socklen_t, int)
man page · May 12, 2006
gethostbyaddr(3) — get network host entryfunctiongethostbyname
struct hostent *gethostbyname(const char *)
man page · May 12, 2006
gethostbyname(3) — get network host entryfunctiongethostent
struct hostent *gethostent(void)
man page · May 12, 2006
gethostent(3) — get network host entryfunctiongetnameinfo
int getnameinfo( const struct sockaddr * __restrict, socklen_t, char * __restrict, socklen_t, char * __restrict, socklen_t, int )
man page · February 28, 2007
getnameinfo(3) — socket address structure to hostname and service namefunctiongetnetbyaddr
struct netent *getnetbyaddr(uint32_t, int)
man page · June 4, 1993
getnetbyaddr(3) — get network entryfunctiongetnetbyname
struct netent *getnetbyname(const char *)
man page · June 4, 1993
getnetbyname(3) — get network entryfunctiongetnetent
struct netent *getnetent(void)
man page · June 4, 1993
getnetent(3) — get network entryfunctiongetprotobyname
struct protoent *getprotobyname(const char *)
man page · June 4, 1993
getprotobyname(3) — get protocol entryfunctiongetprotobynumber
struct protoent *getprotobynumber(int)
man page · June 4, 1993
getprotobynumber(3) — get protocol entryfunctiongetprotoent
struct protoent *getprotoent(void)
man page · June 4, 1993
getprotoent(3) — get protocol entryfunctiongetservbyname
struct servent *getservbyname(const char *, const char *)
man page · July 9, 1995
getservbyname(3) — get service entryfunctiongetservbyport
struct servent *getservbyport(int, const char *)
man page · July 9, 1995
getservbyport(3) — get service entryfunctiongetservent
struct servent *getservent(void)
man page · July 9, 1995
getservent(3) — get service entryfunctionsetnetent
void setnetent(int)
void sethostfile(const char *);
man page · June 4, 1993
setnetent(3) — get network entryfunctionfreehostent
void freehostent(struct hostent *)
man page · August 6, 2004
freehostent(3) — nodename-to-address and address-to-nodename translationfunctiongethostbyname2
struct hostent *gethostbyname2(const char *, int)
man page · May 12, 2006
gethostbyname2(3) — get network host entryfunctiongetipnodebyaddr
struct hostent *getipnodebyaddr(const void *, size_t, int, int *)
man page · August 6, 2004
getipnodebyaddr(3) — nodename-to-address and address-to-nodename translationfunctiongetipnodebyname
struct hostent *getipnodebyname(const char *, int, int, int *)
man page · August 6, 2004
getipnodebyname(3) — nodename-to-address and address-to-nodename translationfunctiongetrpcbyname
struct rpcent *getrpcbyname(const char *name)
man page · December 14, 1987
getrpcbyname(3) — get RPC entryfunctiongetrpcbynumber
struct rpcent *getrpcbynumber(int number)
man page · December 14, 1987
getrpcbynumber(3) — get RPC entryfunctiongetrpcent
struct rpcent *getrpcent(void)
man page · December 14, 1987
getrpcent(3) — get RPC entryfunctionsetrpcent
void setrpcent(int stayopen)
man page · December 14, 1987
setrpcent(3) — get RPC entryfunctionhstrerror
const char *hstrerror(int)
man page · May 12, 2006
hstrerror(3) — get network host entryfunctioninnetgr
int innetgr(const char *, const char *, const char *, const char *)
man page · June 4, 1993
innetgr(3) — netgroup database operationsfunctiongetnetgrent
int getnetgrent(char **, char **, char **)
man page · June 4, 1993
getnetgrent(3) — netgroup database operationsfunctionendnetgrent
void endnetgrent(void)
man page · June 4, 1993
endnetgrent(3) — netgroup database operationsfunctionsetnetgrent
void setnetgrent(const char *)
man page · June 4, 1993
setnetgrent(3) — netgroup database operations