1 .\" $OpenBSD: bindresvport.3,v 1.25 2013/06/05 03:39:23 tedu Exp $
3 .\" Copyright (c) 2010, Oracle America, Inc.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are
9 .\" * Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" * Redistributions in binary form must reproduce the above
12 .\" copyright notice, this list of conditions and the following
13 .\" disclaimer in the documentation and/or other materials
14 .\" provided with the distribution.
15 .\" * Neither the name of the "Oracle America, Inc." nor the names of its
16 .\" contributors may be used to endorse or promote products derived
17 .\" from this software without specific prior written permission.
19 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 .\" COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24 .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
26 .\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 .\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 .Dd $Mdocdate: June 5 2013 $
38 .Nd bind a socket to a privileged IP port
43 .Fn bindresvport "int sd" "struct sockaddr_in *sin"
45 .Fn bindresvport_sa "int sd" "struct sockaddr *sa"
51 functions are used to bind a socket descriptor to a privileged IP
52 port, that is, a port number in the range 0-1023.
55 function operates solely on
59 function is capable of binding both
65 Only the superuser may bind to a privileged port;
66 these functions will fail for any other user.
69 should be a socket descriptor that was returned by a call to
74 is not the NULL pointer,
76 must be initialized to the address family of the socket
82 will attempt to use the specified port.
83 Otherwise, a free port in the range 600-1023 will be chosen and,
88 will be updated with the port that was assigned.
92 is the NULL pointer, a free port in the range 600-1023 will be chosen
93 (as above), but in this case there is no way for
95 to communicate to the caller which port was assigned.
98 returns 0 if it is successful, otherwise \-1 is returned and
100 set to reflect the cause of the error.
108 is not a valid descriptor.
112 .It Bq Er EADDRNOTAVAIL
113 The specified address is not available from the local machine.
115 The specified address is already in use.
117 The socket is already bound to an address.
119 The family of the socket and that requested in
123 The requested address is protected, and the current user
124 has inadequate permission to access it.
128 parameter is not in a valid part of the user
131 Insufficient resources were available in the system
132 to perform the operation.
133 .It Bq Er EPFNOSUPPORT
134 The protocol family has not been configured into the
135 system, no implementation for it exists,
136 or address family did not match between arguments.