− bind a socket to a privileged IP port
bindresvport(int sockfd, struct sockaddr_in
is used to bind a socket descriptor to a privileged
anonymous IP port, that is, a port number arbitrarily
selected from the range 512 to 1023.
bind(2) performed by bindresvport() is
successful, and sin is not NULL, then
sin−>sin_port returns the port number
be NULL, in which case sin−>sin_family is
implicitly taken to be AF_INET. However, in this
case, bindresvport() has no way to return the port
number actually allocated. (This information can later be
obtained using getsockname(2).)
returns 0 on success; otherwise −1 is returned and
errno set to indicate the cause of the error.
can fail for any of the same reasons as bind(2). In
addition, the following errors may occur:
The caller did not have superuser privilege (to be
precise: the CAP_NET_BIND_SERVICE capability is
All privileged ports are in
(EPFNOSUPPORT in glibc 2.7 and earlier)
sin is not NULL and
sin->sin_family is not AF_INET.
explanation of the terms used in this section, see
bindresvport() function uses a static variable that
was not protected by a lock before glibc 2.17, rendering the
Not in POSIX.1.
Present on the BSDs, Solaris, and many other systems.
bindresvport() implementations, the glibc
implementation ignores any value that the caller supplies in
This page is
part of release 4.04 of the Linux man-pages project.
A description of the project, information about reporting
bugs, and the latest version of this page, can be found at