xref: /freebsd/lib/libc/rpc/bindresvport.3 (revision ce834215a70ff69e7e222827437116eee2f9ac6f)
1.\" @(#)bindresvport.3n	2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI
2.Dd November 22, 1987
3.Dt BINDRESVPORT 3
4.Os
5.Sh NAME
6.Nm bindresvport
7.Ndbind a socket to a privileged IP port
8.Sh SYNOPSIS
9.Fd #include <sys/types.h>
10.Fd #include <netinet/in.h>
11.Ft int
12.Fn bindresvport "int sd" "struct sockaddr_in **sin"
13.Sh DESCRIPTION
14.Nm Bindresvport
15is used to bind a socket descriptor to a privileged
16.Tn IP
17port, that is, a
18port number in the range 0-1023.
19The routine returns 0 if it is successful,
20otherwise -1 is returned and
21.Va errno
22set to reflect the cause of the error.
23.Pp
24Only root can bind to a privileged port; this call will fail for any
25other users.
26.Pp
27If the value of sin->sin_port is non-zero
28.Fn bindresvport
29will attempt to use that specific port.  If it fails, it chooses another
30privileged port automatically.
31