Library /sys$common/syshlp/HELPLIB.HLB  —  TCPIP Services, Programming Interfaces, Socket API Functions, connect()
    Initiates a connection on a socket.
    The $QIO equivalent is the IO$_ACCESS system service.
    Format
      #include  <types.h>
      #include  <socket.h>
      int connect  ( int s, struct sockaddr *name, int namelen );
                   (_DECC_V4_SOURCE)
      int connect  ( int s, const struct sockaddr *name, size_t
                   namelen ); (not_DECC_V4_SOURCE)

1  –  Arguments

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

2  –  Description

    This function initiates a connection on a socket.
    If s is a socket descriptor of type SOCK_DGRAM, then this call
    permanently specifies the peer where the data is sent. If s is of
    type SOCK_STREAM, then this call attempts to make a connection to
    the specified socket.
    If a call to connect() fails for a connection-mode socket,
    applications should use close() to deallocate the socket
    and descriptor. If attempting to reinitiate the connection,
    applications should create a new socket.
    Related Functions
    See also accept(), select(),  socket(), getsockname(), and
    shutdown().

3  –  Return Values

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

4  –  Errors

    EADDRINUSE         Configuration problem. There are insufficient
                       ports available for the attempted connection.
                       The inet subsystem attribute ipport_
                       userreserved should be increased.
    EADDRNOTAVAIL      The specified address is not available from
                       the local machine.
    EAFNOSUPPORT       The addresses in the specified address family
                       cannot be used with this socket.
    EALREADY           A connection request is already in progress
                       for the specified socket.
    EBADF              The socket descriptor is invalid.
    ECONNREFUSED       The attempt to connect was rejected.
    EFAULT             The name argument is not a valid part of the
                       user address space.
    EHOSTUNREACH       The specified host is not reachable.
    EINPROGRESS        O_NONBLOCK is set for the file descriptor
                       for the socket, and the connection cannot be
                       immediately established; the connection will
                       be established asynchronously.
    EINTR              The connect() function was interrupted by a
                       signal while waiting for the connection to be
                       established. Once established, the connection
                       may continue asynchronously.
    EINVAL             The value of the namelen argument is invalid
                       for the specified address family, or the sa_
                       family member in the socket address structure
                       is invalid for the protocol.
    EISCONN            The socket is already connected.
    ELOOP              Too many symbolic links were encountered in
                       translating the file specification in the
                       address.
    ENETDOWN           The local network connection is not
                       operational.
    ENETUNREACH        No route to the network or host is present.
    ENOBUFS            The system has insufficient resources to
                       complete the call.
    ENOTSOCK           The socket descriptor is invalid.
    EOPNOTSUPP         The socket is listening and cannot be
                       connected.
    EPROTOTYPE         The specified address has a different type
                       than the socket bound to the specified peer
                       address.
    ETIMEDOUT          The connection request timed out without
                       establishing a connection.
    EWOULDBLOCK        The socket is nonblocking, and the connection
                       cannot be completed immediately. It is
                       possible to use the select() function to
                       select the socket for writing.
Close Help