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