1 .\" Copyright (C) 2007, Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" and Copyright (C) 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" 2007-05-31, mtk: Rewrite and substantial additional text.
25 .\" 2008-12-03, mtk: Rewrote some pieces and fixed some errors
27 .TH BINDRESVPORT 3 2008-12-03 "" "Linux Programmer's Manual"
29 bindresvport \- bind a socket to a privileged IP port
32 .B #include <sys/types.h>
33 .B #include <netinet/in.h>
35 .BI "int bindresvport(int " sockfd ", struct sockaddr_in *" sin );
40 is used to bind a socket descriptor to a privileged anonymous IP port,
41 that is, a port number arbitrarily selected from the range 512 to 1023.
42 .\" Glibc actually starts searching with a port # in the range 600 to 1023
52 returns the port number actually allocated.
55 can be NULL, in which case
57 is implicitly taken to be
59 However, in this case,
61 has no way to return the port number actually allocated.
62 (This information can later be obtained using
66 returns 0 on success; otherwise \-1 is returned and
68 set to indicate the cause of the error.
71 can fail for any of the same reasons as
73 In addition, the following errors may occur:
76 The caller did not have superuser privilege (to be precise: the
77 .B CAP_NET_BIND_SERVICE
78 capability is required).
81 All privileged ports are in use.
83 .BR EAFNOSUPPORT " (" EPFNOSUPPORT " in glibc 2.7 and earlier)"
91 Present on the BSDs, Solaris, and many other systems.
96 the glibc implementation ignores any value that the caller supplies in