.Dt GETADDRINFO 3
.Os
.Sh NAME
-.Nm getaddrinfo ,
-.Nm freeaddrinfo
+.Nm freeaddrinfo ,
+.Nm getaddrinfo
.Nd socket address structure to host and service name
.Sh SYNOPSIS
-.Fd #include <sys/types.h>
.Fd #include <sys/socket.h>
.Fd #include <netdb.h>
-.Ft int
-.Fn getaddrinfo "const char *hostname" "const char *servname" \
- "const struct addrinfo *hints" "struct addrinfo **res"
.Ft void
-.Fn freeaddrinfo "struct addrinfo *ai"
+.Fo freeaddrinfo
+.Fa "struct addrinfo *ai"
+.Fc
+.Ft int
+.Fo getaddrinfo
+.Fa "const char *restrict nodename"
+.Fa "const char *restrict servname"
+.Fa "const struct addrinfo *restrict hints"
+.Fa "struct addrinfo **restrict res"
+.Fc
.Sh DESCRIPTION
The
.Fn getaddrinfo
function is used to get a list of
.Tn IP
addresses and port numbers for host
-.Fa hostname
+.Fa nodename
and service
.Fa servname .
It is a replacement for and provides more flexibility than the
functions.
.Pp
The
-.Fa hostname
+.Fa nodename
and
.Fa servname
arguments are either pointers to NUL-terminated strings or the null pointer.
An acceptable value for
-.Fa hostname
+.Fa nodename
is either a valid host name or a numeric host address string consisting
of a dotted decimal IPv4 address or an IPv6 address.
The
is either a decimal port number or a service name listed in
.Xr services 5 .
At least one of
-.Fa hostname
+.Fa nodename
and
.Fa servname
must be non-null.
If the
.Dv AI_NUMERICHOST
bit is set, it indicates that
-.Fa hostname
+.Fa nodename
should be treated as a numeric string defining an IPv4 or IPv6 address
and no name resolution should be attempted.
.It Dv AI_PASSIVE
is intended for use in a call to
.Xr bind 2 .
In this case, if the
-.Fa hostname
+.Fa nodename
argument is the null pointer, then the IP address portion of the
socket address structure will be set to
.Dv INADDR_ANY
.Tn IP
address portion of the socket address structure will be set to the
loopback address if
-.Fa hostname
+.Fa nodename
is the null pointer and
.Dv AI_PASSIVE
is not set.
}
freeaddrinfo(res0);
.Ed
+.Sh LEGACY SYNOPSIS
+.Fd #include <sys/types.h>
+.Fd #include <sys/socket.h>
+.Fd #include <netdb.h>
+.Pp
+The include file
+.In sys/types.h
+is necessary.
.Sh SEE ALSO
.Xr bind 2 ,
.Xr connect 2 ,
draft specification and documented in
.Dv "RFC 3493" ,
.Dq Basic Socket Interface Extensions for IPv6 .
-.Sh BUGS
-The implementation of
-.Fn getaddrinfo
-is not thread-safe.