*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->OpenBSD man pages -> bindresvport_sa (3)              
Title
Content
Arch
Section
 

BINDRESVPORT(3)

Contents


NAME    [Toc]    [Back]

     bindresvport, bindresvport_sa - bind a socket  to  a  privileged IP port

SYNOPSIS    [Toc]    [Back]

     #include <sys/types.h>
     #include <netinet/in.h>

     int
     bindresvport(int sd, struct sockaddr_in *sin);

     int
     bindresvport_sa(int sd, struct sockaddr *sa);

DESCRIPTION    [Toc]    [Back]

     The  bindresvport() and bindresvport_sa() functions are used
to bind a
     socket descriptor to a privileged IP port, that is,  a  port
number in the
     range  0-1023.   The bindresvport() function operates solely
on AF_INET
     sockets, whereas the bindresvport_sa() function  is  capable
of binding
     both AF_INET and AF_INET6 sockets.

     Only  the  superuser  may  bind  to a privileged port; these
functions will
     fail for any other user.

     sd should be a socket descriptor that was returned by a call
to
     socket(2).

     If sin is not the NULL pointer, sin->sin_family must be initialized to
     the address family of  the  socket  sd.   If  the  value  of
sin->sin_port is
     non-zero,  bindresvport()  will attempt to use the specified
port.  Otherwise,
 a free port in the range 600-1023 will be chosen  and,
if the
     bind(2)  succeeds,  sin->sin_port  will  be updated with the
port that was
     assigned.

     If sin is the  NULL  pointer,  a  free  port  in  the  range
600-1023 will be
     chosen  (as  above),  but  in  this case there is no way for
bindresvport() to
     communicate to the caller which port was assigned.

RETURN VALUES    [Toc]    [Back]

     bindresvport() returns 0 if it is successful,  otherwise  -1
is returned
     and errno set to reflect the cause of the error.

ERRORS    [Toc]    [Back]

     The bindresvport() function fails if:

     [EBADF]       sd is not a valid descriptor.

     [ENOTSOCK]    sd is not a socket.

     [EADDRNOTAVAIL]
                   The  specified  address  is not available from
the local machine.


     [EADDRINUSE]  The specified address is already in use.

     [EINVAL]      The socket is already bound to an address.

     [EINVAL]      The family of the socket and that requested in
                   sa->sa_family are not equivalent.

     [EACCES]       The  requested  address is protected, and the
current user
                   has inadequate permission to access it.

     [EFAULT]      The name parameter is not in a valid  part  of
the user address
 space.

     [ENOBUFS]      Insufficient  resources were available in the
system to perform
 the operation.

     [EPFNOSUPPORT]
                   The protocol family has  not  been  configured
into the system,
  no  implementation for it exists, or address family did
                   not match between arguments.

SEE ALSO    [Toc]    [Back]

      
      
     bind(2), socket(2), rresvport(3), rresvport_af(3)

OpenBSD     3.6                          August      9,      1997
[ Back ]
 Similar pages
Name OS Title
cap_bind IRIX bind a privileged name to a socket
rresvport Tru64 Retrieve a socket with a privileged address
rresvport_af Tru64 Retrieve a socket with a privileged address
bind NetBSD bind a name to a socket
bind Linux bind a name to a socket
bind OpenBSD bind a name to a socket
bind Tru64 Bind a name to a socket
bind IRIX bind a name to a socket
bind IRIX bind a name to a socket
bind HP-UX bind an address to a socket
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service