If the process has appropriate privilege, the bindresvport() function shall bind a socket to an anonymous privileged IP port, that is, arbitrarily selected from the range 512 through 1023.
If the bind is successful and sin
NULL, and the port number
bound to is returned in the
member of sin.
Any caller-supplied value of
If sin is
the address family is taken to be
AF_INET and an available
privileged port is bound to.
Since there is no sockaddr_in
structure, the port number chosen cannot be returned.
The getsockname() may be used to
query for this information.
On success, 0 is returned.
On error, -1 is returned and
errno is set to indicate the error.
bindresvport() may fail in the same way as bind() in POSIX 1003.1-2001 (ISO/IEC 9945-2003). The following additional or differing failures may occur:
All privileged ports are in use.
The specified address is not a valid address for the address family of the specified socket, or the address family is not supported.
The same meaning as
Note: At this time, only
AF_INETis supported. Applications should be prepared for either the
EPFNOSUPPORTerror to be indicated.