2 .\" Copyright (C) 2007, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" and Copyright (C) 2008, Linux Foundation, written by Michael Kerrisk
4 .\" <mtk.manpages@gmail.com>
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
8 .\" 2007-05-31, mtk: Rewrite and substantial additional text.
9 .\" 2008-12-03, mtk: Rewrote some pieces and fixed some errors
11 .TH bindresvport 3 (date) "Linux man-pages (unreleased)"
13 bindresvport \- bind a socket to a privileged IP port
16 .RI ( libc ", " \-lc )
19 .B #include <sys/types.h>
20 .B #include <netinet/in.h>
22 .BI "int bindresvport(int " sockfd ", struct sockaddr_in *" sin );
26 is used to bind the socket referred to by the
29 to a privileged anonymous IP port,
30 that is, a port number arbitrarily selected from the range 512 to 1023.
31 .\" glibc actually starts searching with a port # in the range 600 to 1023
41 returns the port number actually allocated.
44 can be NULL, in which case
46 is implicitly taken to be
48 However, in this case,
50 has no way to return the port number actually allocated.
51 (This information can later be obtained using
55 returns 0 on success; otherwise \-1 is returned and
57 is set to indicate the error.
60 can fail for any of the same reasons as
62 In addition, the following errors may occur:
65 The calling process was not privileged
66 (on Linux: the calling process did not have the
67 .B CAP_NET_BIND_SERVICE
68 capability in the user namespace governing its network namespace).
71 All privileged ports are in use.
73 .BR EAFNOSUPPORT " (" EPFNOSUPPORT " in glibc 2.7 and earlier)"
80 For an explanation of the terms used in this section, see
86 Interface Attribute Value
94 glibc\ >=\ 2.17: MT-Safe;
95 .\" commit f6da27e53695ad1cc0e2a9490358decbbfdff5e5
96 glibc\ <\ 2.17: MT-Unsafe
103 function uses a static variable that was not protected by a lock
104 before glibc 2.17, rendering the function MT-Unsafe.
106 Present on the BSDs, Solaris, and many other systems.
111 the glibc implementation ignores any value that the caller supplies in