bindresvport — bind a socket to a privileged IP port
#include <sys/types.h> #include <netinet/in.h>
int
bindresvport( |
int | sd, |
struct sockaddr_in ** | sin) ; |
bindresvport
() is used to
bind a socket descriptor to a privileged IP port, that is, a
port number in the range 0-1023.
If in−>sin_port
is 0
then an anonymous port in the range 600 to 1023 be chosen. If
the bind(2) performed by
bindresvport
() is successful,
then sin−>sin_port
returns the port number actually allocated.
sin
can be NULL,
in which case sin−>sin_family
is
implicitly taken to be AF_INET
,
and an anonymous port is allocated (as above). However, in
this case, bindresvport
() has
no way to return the port number actually allocated.
bindresvport
() returns 0 if
it is successful, otherwise −1 is returned and
errno
set to indicate the cause
of the error.
Only root can bind to a privileged port; this call will fail for any other users. In addition, the following error may occur:
sin
is not
NULL and sin−>sin_family
is not AF_INET
.
This page is part of release 2.79 of the Linux man-pages
project. A
description of the project, and information about reporting
bugs, can be found at
http://www.kernel.org/doc/man-pages/.
This page was initially taken from the 4.4BSD-Lite CDROM (BSD license) with substantial updates Copyright (C) 2007, Michael Kerrisk <mtk.manpagesgmail.com> (#)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. |