bindresvport(3N)
Requires Optional NFS Services Software
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
bindresvport is used to bind 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(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 the super-user can bind to a privileged port; this call will fail for any other users.
RETURN VALUE
bindresvport returns 0 if it is successful, otherwise −1 is returned and errno is set to reflect the cause of the error.
ERRORS
bindresvport fails if one of the following conditions is true:
[EPFNOSUPPORT] The value specified in the sin_family field of the sockaddr_in struct was not AF_INET.
[EBADF] sd is not a valid descriptor.
[ENOTSOCK] sd is not a socket.
[EADDRNOTAVAIL] The specified address is bad or not available from the local machine.
[EADDRINUSE] The specified address is already in use.
[EINVAL] The socket is already bound to an address, or the socket has been shut down.
[EAFNOSUPPORT] Requested address does not match the address family of this socket.
[EACCESS] The requested address is protected, and the current user has inadequate permission to access it.
[EOPNOTSUPP] The socket whose descriptor is s is of a type which does not support address binding.
[ENOBUFS] Insufficient buffer memory is available.
AUTHOR
bindresvp was developed by Sun Microsystems, Inc.
SEE ALSO
Hewlett-Packard Company — HP-UX Release 8.05: June 1991