Blame man-pages-posix-2013-a/man0p/netdb.h.0p

Packit 7cfc04
'\" et
Packit 7cfc04
.TH netdb.h "0P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
Packit 7cfc04
.SH PROLOG
Packit 7cfc04
This manual page is part of the POSIX Programmer's Manual.
Packit 7cfc04
The Linux implementation of this interface may differ (consult
Packit 7cfc04
the corresponding Linux manual page for details of Linux behavior),
Packit 7cfc04
or the interface may not be implemented on Linux.
Packit 7cfc04
Packit 7cfc04
.SH NAME
Packit 7cfc04
netdb.h
Packit 7cfc04
\(em definitions for network database operations
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.LP
Packit 7cfc04
.nf
Packit 7cfc04
#include <netdb.h>
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header may define the
Packit 7cfc04
.BR in_port_t
Packit 7cfc04
type and the
Packit 7cfc04
.BR in_addr_t
Packit 7cfc04
type as described in
Packit 7cfc04
.IR <netinet/in.h> .
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the
Packit 7cfc04
.BR hostent
Packit 7cfc04
structure, which shall include at least the following members:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
char   *h_name       \fROfficial name of the host.\fR
Packit 7cfc04
char  **h_aliases    \fRA pointer to an array of pointers to\fR
Packit 7cfc04
                     \fRalternative host names, terminated by a\fR
Packit 7cfc04
                     \fRnull pointer.\fR
Packit 7cfc04
int     h_addrtype   \fRAddress type.\fR
Packit 7cfc04
int     h_length     \fRThe length, in bytes, of the address.\fR
Packit 7cfc04
char  **h_addr_list  \fRA pointer to an array of pointers to network\fR
Packit 7cfc04
                     \fRaddresses (in network byte order) for the host,\fR
Packit 7cfc04
                     \fRterminated by a null pointer.\fR
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the
Packit 7cfc04
.BR netent
Packit 7cfc04
structure, which shall include at least the following members:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
char     *n_name      \fROfficial, fully-qualified (including the\fR
Packit 7cfc04
                      \fRdomain) name of the host.\fR
Packit 7cfc04
char    **n_aliases   \fRA pointer to an array of pointers to\fR
Packit 7cfc04
                      \fRalternative network names, terminated by a\fR
Packit 7cfc04
                      \fRnull pointer.\fR
Packit 7cfc04
int       n_addrtype  \fRThe address type of the network.\fR
Packit 7cfc04
uint32_t  n_net       \fRThe network number, in host byte order.\fR
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the
Packit 7cfc04
.BR uint32_t
Packit 7cfc04
type as described in
Packit 7cfc04
.IR <inttypes.h> .
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the
Packit 7cfc04
.BR protoent
Packit 7cfc04
structure, which shall include at least the following members:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
char   *p_name     \fROfficial name of the protocol.\fR
Packit 7cfc04
char  **p_aliases  \fRA pointer to an array of pointers to\fR
Packit 7cfc04
                   \fRalternative protocol names, terminated by\fR
Packit 7cfc04
                   \fRa null pointer.\fR
Packit 7cfc04
int     p_proto    \fRThe protocol number.\fR
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the
Packit 7cfc04
.BR servent
Packit 7cfc04
structure, which shall include at least the following members:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
char   *s_name     \fROfficial name of the service.\fR
Packit 7cfc04
char  **s_aliases  \fRA pointer to an array of pointers to\fR
Packit 7cfc04
                   \fRalternative service names, terminated by\fR
Packit 7cfc04
                   \fRa null pointer.\fR
Packit 7cfc04
int     s_port     \fRA value which, when converted to uint16_t,\fR
Packit 7cfc04
                   \fRyields the port number in network byte order\fR
Packit 7cfc04
                   \fRat which the service resides.\fR
Packit 7cfc04
char   *s_proto    \fRThe name of the protocol to use when\fR
Packit 7cfc04
                   \fRcontacting the service.\fR
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the IPPORT_RESERVED symbolic constant with the
Packit 7cfc04
value of the highest reserved Internet port number.
Packit 7cfc04
.SS "Address Information Structure"
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the
Packit 7cfc04
.BR addrinfo
Packit 7cfc04
structure, which shall include at least the following members:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
int               ai_flags      \fRInput flags.\fR
Packit 7cfc04
int               ai_family     \fRAddress family of socket.\fR
Packit 7cfc04
int               ai_socktype   \fRSocket type.\fR
Packit 7cfc04
int               ai_protocol   \fRProtocol of socket.\fR
Packit 7cfc04
socklen_t         ai_addrlen    \fRLength of socket address.\fR
Packit 7cfc04
struct sockaddr  *ai_addr       \fRSocket address of socket.\fR
Packit 7cfc04
char             *ai_canonname  \fRCanonical name of service location.\fR
Packit 7cfc04
struct addrinfo  *ai_next       \fRPointer to next in list.\fR
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the following symbolic constants that evaluate to
Packit 7cfc04
bitwise-distinct integer constants for use in the
Packit 7cfc04
.IR flags
Packit 7cfc04
field of the
Packit 7cfc04
.BR addrinfo
Packit 7cfc04
structure:
Packit 7cfc04
.IP AI_PASSIVE 14
Packit 7cfc04
Socket address is intended for
Packit 7cfc04
\fIbind\fR().
Packit 7cfc04
.IP AI_CANONNAME 14
Packit 7cfc04
Request for canonical name.
Packit 7cfc04
.IP AI_NUMERICHOST 14
Packit 7cfc04
Return numeric host address as name.
Packit 7cfc04
.IP AI_NUMERICSERV 14
Packit 7cfc04
Inhibit service name resolution.
Packit 7cfc04
.IP AI_V4MAPPED 14
Packit 7cfc04
If no IPv6 addresses are found, query for IPv4 addresses and return
Packit 7cfc04
them to the caller as IPv4-mapped IPv6 addresses.
Packit 7cfc04
.IP AI_ALL 14
Packit 7cfc04
Query for both IPv4 and IPv6 addresses.
Packit 7cfc04
.IP AI_ADDRCONFIG 14
Packit 7cfc04
Query for IPv4 addresses only when an IPv4 address is configured;
Packit 7cfc04
query for IPv6 addresses only when an IPv6 address is configured.
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the following symbolic constants that evaluate
Packit 7cfc04
to bitwise-distinct integer constants for use in the
Packit 7cfc04
.IR flags
Packit 7cfc04
argument to
Packit 7cfc04
\fIgetnameinfo\fR():
Packit 7cfc04
.IP NI_NOFQDN 14
Packit 7cfc04
Only the nodename portion of the FQDN is returned for local hosts.
Packit 7cfc04
.IP NI_NUMERICHOST 14
Packit 7cfc04
The numeric form of the node's address is returned instead of its
Packit 7cfc04
name.
Packit 7cfc04
.IP NI_NAMEREQD 14
Packit 7cfc04
Return an error if the node's name cannot be located in the database.
Packit 7cfc04
.IP NI_NUMERICSERV 14
Packit 7cfc04
The numeric form of the service address is returned instead of its name.
Packit 7cfc04
.IP NI_NUMERICSCOPE 14
Packit 7cfc04
.br
Packit 7cfc04
For IPv6 addresses, the numeric form of the scope identifier is
Packit 7cfc04
returned instead of its name.
Packit 7cfc04
.IP NI_DGRAM 14
Packit 7cfc04
Indicates that the service is a datagram service (SOCK_DGRAM).
Packit 7cfc04
.SS "Address Information Errors"
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the following symbolic constants for use as
Packit 7cfc04
error values for
Packit 7cfc04
\fIgetaddrinfo\fR()
Packit 7cfc04
and
Packit 7cfc04
\fIgetnameinfo\fR().
Packit 7cfc04
The values shall be suitable for use in
Packit 7cfc04
.BR #if
Packit 7cfc04
preprocessing directives.
Packit 7cfc04
.IP EAI_AGAIN 14
Packit 7cfc04
The name could not be resolved at this time. Future attempts may
Packit 7cfc04
succeed.
Packit 7cfc04
.IP EAI_BADFLAGS 14
Packit 7cfc04
The flags had an invalid value.
Packit 7cfc04
.IP EAI_FAIL 14
Packit 7cfc04
A non-recoverable error occurred.
Packit 7cfc04
.IP EAI_FAMILY 14
Packit 7cfc04
The address family was not recognized or the address length was invalid
Packit 7cfc04
for the specified family.
Packit 7cfc04
.IP EAI_MEMORY 14
Packit 7cfc04
There was a memory allocation failure.
Packit 7cfc04
.IP EAI_NONAME 14
Packit 7cfc04
The name does not resolve for the supplied parameters.
Packit 7cfc04
.RS 14 
Packit 7cfc04
.P
Packit 7cfc04
NI_NAMEREQD is set and the host's name cannot be located, or both
Packit 7cfc04
.IR nodename
Packit 7cfc04
and
Packit 7cfc04
.IR servname
Packit 7cfc04
were null.
Packit 7cfc04
.RE
Packit 7cfc04
.IP EAI_SERVICE 14
Packit 7cfc04
The service passed was not recognized for the specified socket type.
Packit 7cfc04
.IP EAI_SOCKTYPE 14
Packit 7cfc04
The intended socket type was not recognized.
Packit 7cfc04
.IP EAI_SYSTEM 14
Packit 7cfc04
A system error occurred. The error code can be found in
Packit 7cfc04
.IR errno .
Packit 7cfc04
.IP EAI_OVERFLOW 14
Packit 7cfc04
An argument buffer overflowed.
Packit 7cfc04
.P
Packit 7cfc04
The following shall be declared as functions and may also be defined as
Packit 7cfc04
macros. Function prototypes shall be provided.
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
void              endhostent(void);
Packit 7cfc04
void              endnetent(void);
Packit 7cfc04
void              endprotoent(void);
Packit 7cfc04
void              endservent(void);
Packit 7cfc04
void              freeaddrinfo(struct addrinfo *);
Packit 7cfc04
const char       *gai_strerror(int);
Packit 7cfc04
int               getaddrinfo(const char *restrict, const char *restrict,
Packit 7cfc04
                      const struct addrinfo *restrict,
Packit 7cfc04
                      struct addrinfo **restrict);
Packit 7cfc04
struct hostent   *gethostent(void);
Packit 7cfc04
int               getnameinfo(const struct sockaddr *restrict, socklen_t,
Packit 7cfc04
                      char *restrict, socklen_t, char *restrict,
Packit 7cfc04
                      socklen_t, int);
Packit 7cfc04
struct netent    *getnetbyaddr(uint32_t, int);
Packit 7cfc04
struct netent    *getnetbyname(const char *);
Packit 7cfc04
struct netent    *getnetent(void);
Packit 7cfc04
struct protoent  *getprotobyname(const char *);
Packit 7cfc04
struct protoent  *getprotobynumber(int);
Packit 7cfc04
struct protoent  *getprotoent(void);
Packit 7cfc04
struct servent   *getservbyname(const char *, const char *);
Packit 7cfc04
struct servent   *getservbyport(int, const char *);
Packit 7cfc04
struct servent   *getservent(void);
Packit 7cfc04
void              sethostent(int);
Packit 7cfc04
void              setnetent(int);
Packit 7cfc04
void              setprotoent(int);
Packit 7cfc04
void              setservent(int);
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header shall define the
Packit 7cfc04
.BR socklen_t
Packit 7cfc04
type through
Packit 7cfc04
.BR typedef ,
Packit 7cfc04
as described in
Packit 7cfc04
.IR <sys/socket.h> .
Packit 7cfc04
.P
Packit 7cfc04
Inclusion of the
Packit 7cfc04
.IR <netdb.h> 
Packit 7cfc04
header may also make visible all symbols from
Packit 7cfc04
.IR <netinet/in.h> ,
Packit 7cfc04
.IR <sys/socket.h> ,
Packit 7cfc04
and
Packit 7cfc04
.IR <inttypes.h> .
Packit 7cfc04
.LP
Packit 7cfc04
.IR "The following sections are informative."
Packit 7cfc04
.SH "APPLICATION USAGE"
Packit 7cfc04
None.
Packit 7cfc04
.SH "RATIONALE"
Packit 7cfc04
None.
Packit 7cfc04
.SH "FUTURE DIRECTIONS"
Packit 7cfc04
None.
Packit 7cfc04
.SH "SEE ALSO"
Packit 7cfc04
.IR "\fB<inttypes.h>\fP",
Packit 7cfc04
.IR "\fB<netinet_in.h>\fP",
Packit 7cfc04
.IR "\fB<sys_socket.h>\fP"
Packit 7cfc04
.P
Packit 7cfc04
The System Interfaces volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "\fIbind\fR\^(\|)",
Packit 7cfc04
.IR "\fIendhostent\fR\^(\|)",
Packit 7cfc04
.IR "\fIendnetent\fR\^(\|)",
Packit 7cfc04
.IR "\fIendprotoent\fR\^(\|)",
Packit 7cfc04
.IR "\fIendservent\fR\^(\|)",
Packit 7cfc04
.IR "\fIfreeaddrinfo\fR\^(\|)",
Packit 7cfc04
.IR "\fIgai_strerror\fR\^(\|)",
Packit 7cfc04
.IR "\fIgetnameinfo\fR\^(\|)"
Packit 7cfc04
.SH COPYRIGHT
Packit 7cfc04
Portions of this text are reprinted and reproduced in electronic form
Packit 7cfc04
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
Packit 7cfc04
-- Portable Operating System Interface (POSIX), The Open Group Base
Packit 7cfc04
Specifications Issue 7, Copyright (C) 2013 by the Institute of
Packit 7cfc04
Electrical and Electronics Engineers, Inc and The Open Group.
Packit 7cfc04
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
Packit 7cfc04
event of any discrepancy between this version and the original IEEE and
Packit 7cfc04
The Open Group Standard, the original IEEE and The Open Group Standard
Packit 7cfc04
is the referee document. The original Standard can be obtained online at
Packit 7cfc04
http://www.unix.org/online.html .
Packit 7cfc04
Packit 7cfc04
Any typographical or formatting errors that appear
Packit 7cfc04
in this page are most likely
Packit 7cfc04
to have been introduced during the conversion of the source files to
Packit 7cfc04
man page format. To report such errors, see
Packit 7cfc04
https://www.kernel.org/doc/man-pages/reporting_bugs.html .