man-pages/man3/bindresvport.3

74 lines
1.7 KiB
Groff
Raw Normal View History

.\" This page was initially taken from the 4.4BSD-Lite CDROM (BSD license)
2007-06-21 22:55:04 +00:00
.\" with substantial updates
2007-09-20 06:52:22 +00:00
.\" Copyright (C) 2007, Michael Kerrisk <mtk.manpages@gmail.com>
2006-05-31 22:49:02 +00:00
.\"
2004-11-03 13:51:07 +00:00
.\" @(#)bindresvport.3n 2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI
.\"
.\" 2007-05-31, mtk: Rewrite and substantial additional text.
.\"
.TH BINDRESVPORT 3 2007-05-31 "" "Linux Programmer's Manual"
2004-11-03 13:51:07 +00:00
.SH NAME
bindresvport \- bind a socket to a privileged IP port
.SH SYNOPSIS
.nf
.B #include <sys/types.h>
.B #include <netinet/in.h>
.LP
2007-04-03 15:32:52 +00:00
.BI "int bindresvport(int " sd ", struct sockaddr_in **" sin );
2004-11-03 13:51:07 +00:00
.fi
.SH DESCRIPTION
.LP
.BR bindresvport ()
2004-11-03 13:51:07 +00:00
is used to bind a socket descriptor to a privileged
2007-12-24 16:10:29 +00:00
IP
2004-11-03 13:51:07 +00:00
port, that is, a
port number in the range 0-1023.
If
.I in\->sin_port
is 0 then an anonymous port in the range 600 to 1023
be chosen.
If the
.BR bind (2)
2007-06-21 22:55:04 +00:00
performed by
.BR bindresvport ()
is successful, then
.I sin\->sin_port
returns the port number actually allocated.
.I sin
can be NULL, in which case
.I sin\->sin_family
is implicitly taken to be
.BR AF_INET ,
2007-06-21 22:55:04 +00:00
and an anonymous port is allocated (as above).
However, in this case,
.BR bindresvport ()
has no way to return the port number actually allocated.
.SH RETURN VALUE
.BR bindresvport ()
returns 0 if it is successful, otherwise \-1 is returned and
2004-11-10 17:11:31 +00:00
.I errno
set to indicate the cause of the error.
.SH ERRORS
.BR bindresvport ()
can fail for any of the same reasons as
2007-06-01 06:08:41 +00:00
.BR bind (2).
2007-05-21 11:09:59 +00:00
.SH "CONFORMING TO"
Not in POSIX.1-2001.
Present on the BSDs, Solaris, and many other systems.
.SH NOTES
2004-11-03 13:51:07 +00:00
.LP
Only root can bind to a privileged port; this call will fail for any
other users.
In addition, the following error may occur:
.TP
.B EPFNOSUPPORT
.I sin
is not NULL and
.I sin\->sin_family
2007-06-21 22:55:04 +00:00
is not
.BR AF_INET .
.SH SEE ALSO
.BR bind (2)