.\" FIXME . glibc's 2.9 NEWS file documents DCCP and UDP-lite support
.\" and is SCTP support now also there?
.\"
-.TH GETADDRINFO 3 2013-01-15 "GNU" "Linux Programmer's Manual"
+.TH GETADDRINFO 3 2014-04-06 "GNU" "Linux Programmer's Manual"
.SH NAME
getaddrinfo, freeaddrinfo, gai_strerror \- network address and
service translation
.PP
All the other fields in the structure pointed to by
.I hints
-must contain either 0 or a NULL pointer, as appropriate.
+must contain either 0 or a null pointer, as appropriate.
+.PP
Specifying
.I hints
as NULL is equivalent to setting
.I ai_flags
to
.BR "(AI_V4MAPPED\ |\ AI_ADDRCONFIG)" .
-
+(POSIX specifies different defaults for
+.IR ai_flags ;
+see NOTES.)
.I node
specifies either a numerical network address
(for IPv4, numbers-and-dots notation as supported by
.I hints.ai_flags
contains the
.B AI_NUMERICHOST
-flag then
+flag, then
.I node
must be a numerical network address.
The
only if the local system has at least one IPv6 address configured.
The loopback address is not considered for this case as valid
as a configured address.
+This flag is useful on, for example,
+IPv4-only systems, to ensure that
+.BR getaddrinfo ()
+does not return IPv6 socket addresses that would always fail in
+.BR connect (2)
+or
+.BR bind (2).
.PP
If
.I hints.ai_flags
peer_addr_len, host, NI_MAXHOST,
service, NI_MAXSERV, NI_NUMERICSERV);
if (s == 0)
- printf("Received %ld bytes from %s:%s\\n",
- (long) nread, host, service);
+ printf("Received %zd bytes from %s:%s\\n",
+ nread, host, service);
else
fprintf(stderr, "getnameinfo: %s\\n", gai_strerror(s));
exit(EXIT_FAILURE);
}
- printf("Received %ld bytes: %s\\n", (long) nread, buf);
+ printf("Received %zd bytes: %s\\n", nread, buf);
}
exit(EXIT_SUCCESS);
.BR gai.conf (5),
.BR hostname (7),
.BR ip (7)
+.SH COLOPHON
+This page is part of release 3.68 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.