HP-UX Reference (11i v2 04/09) - 3 Library Functions A-M (vol 6)
b
bindresvport(3N) bindresvport(3N)
NAME
bindresvport() - bind socket to privileged IP port
SYNOPSIS
#include <sys/types.h>
#include <netinet/in.h>
int bindresvport(int sd, struct sockaddr_in *sin);
DESCRIPTION
The bindresvport()
function binds a socket descriptor to a privileged IP port; that is, a port number
in the range 0 to 1023.
sd is a socket descriptor that was previously defined by a successful call to
socket() (see socket(2)).
Upon successful completion of
bindresvport()
, the sin_port field in the
struct pointed to by sin
contains the number of the privileged port bound to the sd socket. Due to the need to protect the port
numbers used by various networking commands,
bindresvport()
only returns a port number within
a smaller subrange in the range of 0 to 1023.
Only superuser can bind to a privileged port.
RETURN VALUE
bindresvport() returns the following values:
0 Successful completion.
-1 Failure. errno is set to indicate the error.
ERRORS
If
bindresvport() fails, errno
is set to one of the following values:
[EACCES] The requested address is protected, and the current user has inadequate
permission to access it.
[EADDRINUSE] The specified address is already in use.
[EADDRNOTAVAIL] The specified address is bad or not available from the local machine.
[EAFNOSUPPORT] Requested address does not match the address family of this socket.
[EBADF] sd is not a valid descriptor.
[EINVAL] The socket is already bound to an address, or the socket has been shut
down.
[ENOBUFS] Insufficient buffer memory is available.
[ENOTSOCK] sd is not a socket.
[EOPNOTSUPP] The socket whose descriptor is sd is of a type that does not support address
binding.
[EPFNOSUPPORT] The value specified in the sin_family field of the sockaddr_in struct was not
AF_INET.
AUTHOR
bindresvport() was developed by Sun Microsystems, Inc.
SEE ALSO
bind(2), socket(2).
Section 3−−56 Hewlett-Packard Company − 1 − HP-UX 11i Version 2: September 2004