1BINDRESVPORT(3)            Linux Programmer's Manual           BINDRESVPORT(3)
2
3
4

NAME

6       bindresvport - bind a socket to a privileged IP port
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <netinet/in.h>
11
12       int bindresvport(int sockfd, struct sockaddr_in *sin);
13

DESCRIPTION

15       bindresvport()  is  used  to  bind  a socket descriptor to a privileged
16       anonymous IP port, that is, a port number arbitrarily selected from the
17       range 512 to 1023.
18
19       If  the  bind(2)  performed by bindresvport() is successful, and sin is
20       not NULL, then sin->sin_port returns the  port  number  actually  allo‐
21       cated.
22
23       sin  can  be NULL, in which case sin->sin_family is implicitly taken to
24       be AF_INET.  However, in this case, bindresvport() has no way to return
25       the  port  number  actually  allocated.  (This information can later be
26       obtained using getsockname(2).)
27

RETURN VALUE

29       bindresvport() returns 0 on success; otherwise -1 is returned and errno
30       set to indicate the cause of the error.
31

ERRORS

33       bindresvport()  can  fail  for  any of the same reasons as bind(2).  In
34       addition, the following errors may occur:
35
36       EACCES The caller did not have superuser privilege (to be precise:  the
37              CAP_NET_BIND_SERVICE capability is required).
38
39       EADDRINUSE
40              All privileged ports are in use.
41
42       EAFNOSUPPORT (EPFNOSUPPORT in glibc 2.7 and earlier)
43              sin is not NULL and sin->sin_family is not AF_INET.
44

CONFORMING TO

46       Not in POSIX.1-2001.  Present on the BSDs, Solaris, and many other sys‐
47       tems.
48

NOTES

50       Unlike some bindresvport() implementations,  the  glibc  implementation
51       ignores any value that the caller supplies in sin->sin_port.
52

SEE ALSO

54       bind(2), getsockname(2)
55

COLOPHON

57       This  page  is  part of release 3.25 of the Linux man-pages project.  A
58       description of the project, and information about reporting  bugs,  can
59       be found at http://www.kernel.org/doc/man-pages/.
60
61
62
63                                  2008-12-03                   BINDRESVPORT(3)
Impressum