VMS Help  —  TCPIP Services, Programming Interfaces, Socket API Functions, bind()
    Binds a name to a socket.
    The $QIO equivalent is the IO$_SETMODE system service with the p3
    argument.
    Format
      #include  <types.h>
      #include  <socket.h>
      int bind  ( int s, struct sockaddr *name, int namelen );
                (_DECC_V4_SOURCE)
      int bind  ( int s, const struct sockaddr *name, size_t namelen
                ); (not_DECC_V4_SOURCE)

1  –  Arguments

 s
    A socket descriptor created with the socket() function.
 name
    Address of a structure used to assign a name to the socket in
    the format specific to the family (AF_INET or AF_INET6) socket
    address.
 namelen
    The size, in bytes, of the structure pointed to by name.

2  –  Description

    This function assigns a port number and IP address to an unnamed
    socket. When a socket is created with the socket() function, it
    exists in a name space (address family) but has no name assigned.
    The bind() function requests that a name be assigned to the
    socket.
    Related Functions
    See also connect(), getsockname(),  listen(), and socket().

3  –  Return Values

    0                  Successful completion.
    -1                 Error; errno is set to indicate the error.

4  –  Errors

    EACCESS            The requested address is protected, and the
                       current user has inadequate permission to
                       access it.
    EADDRINUSE         The specified internet address and ports are
                       already in use.
    EADDRNOTAVAIL      The specified address is not available from
                       the local machine.
    EAFNOSUPPORT       The specified address is invalid for the
                       address family of the specified socket.
    EBADF              The socket descriptor is invalid.
    EDESTADDRREQ       The address argument is a null pointer.
    EFAULT             The name argument is not a valid part of the
                       user address space.
    EINVAL             The socket is already bound to an address and
                       the protocol does not support binding to a new
                       address, the socket has been shut down, or the
                       length or the namelen argument is invalid for
                       the address family.
    EISCONN            The socket is already connected.
    EISDIR             The address argument is a null pointer.
    ENOBUFS            The system has insufficient resources to
                       complete the call.
    ENOTSOCK           The socket descriptor is invalid.
    EOPNOTSUPP         The socket type of the specified socket does
                       not support binding to an address.
Close Help