Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ connect(2) — HP-UX 5.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

accept(2)

select(2)

socket(2)

getsockname(2)

socket(4)

     CONNECT(2)               Series 300 Only               CONNECT(2)

     NAME
          connect - initiate a connection on a socket

     SYNOPSIS
          #include <sys/types.h>
          #include <sys/socket.h>

          connect(s, addr, addrlen)
          int s;
          struct sockaddr *addr;
          int addrlen;

     HP-UX COMPATIBILITY
          Level:    HP-UX/NON-STANDARD

          Origin:   UCB

          Remarks:  Implemented on the Series 300 only.

     DESCRIPTION
          The parameter s is a socket descriptor.  Addr is a pointer
          to a socket address structure which contains the address of
          a remote socket to which a connection will be established.
          Addrlen is the size of this address structure.

          If the socket is of type SOCK_DGRAM, then connect
          permanently specifies the remote socket (peer) to which
          messages are to be sent, and the call returns immediately.
          Furthermore, this socket is no longer capable of receiving
          messages sent from sockets other than its peer.

          If the socket is of type SOCK_STREAM, then connect attempts
          to contact the remote host in order to make a connection
          between the remote socket (peer) and the local socket
          specified by s.  The call will normally block until the
          connection completes.  If the socket is in non-blocking mode
          (see socket(4)), then an EINPROGRESS error is returned by
          the call.  In this case, the select(2) call may be used on
          this socket to determine when the connection has completed
          by selecting it for writing.

          If s is a SOCK_STREAM socket that is bound to the same local
          address as another SOCK_STREAM socket, connect will return
          EADDRINUSE if addr is the same as the peer address of that
          other socket.  This situation can only happen if the
          SO_REUSEADDR option has been set on this socket (see
          socket(2)).

          If the socket does not already have a local name bound to it
          (see bind(2)), the connect call will also bind the socket to
          a local address chosen by the system.

     Hewlett-Packard               - 1 -             (printed 7/16/86)

     CONNECT(2)               Series 300 Only               CONNECT(2)

          The connect call fails if:

          [EBADF]             S is not a valid descriptor.

          [ENOTSOCK]          S is a descriptor for a file, not a
                              socket.

          [EADDRNOTAVAIL]     The specified address is not available
                              on this machine.

          [EAFNOSUPPORT]      Addresses in the specified address
                              family cannot be used with this socket.

          [EISCONN]           The socket is already connected.

          [EINVAL]            The socket has already been shut down,
                              has a listen active on it, or addrlen is
                              a bad value.

          [ETIMEDOUT]         Connection establishment timed out
                              without establishing a connection.

          [ECONNREFUSED]      The attempt to connect was forcefully
                              rejected.

          [ENETUNREACH]       The network isn't reachable from this
                              host.

          [EADDRINUSE]        The address is already in use.

          [EFAULT]            The addr parameter is not a valid
                              pointer.

          [EINPROGRESS]       The socket is non-blocking and the
                              connection cannot be completed
                              immediately.

          [ENOBUFS]           No buffer space is available.  The
                              connect has failed.

          [EINTR]             The connect was interrupted by delivery
                              of a signal before the connect sequence
                              was complete.  The building of the
                              connection still takes place even though
                              the user is not blocked on the connect
                              call.

          [EOPNOTSUPP]        A connect attempt was made on a socket
                              type which does not support this call.

          [ENET]              A hardware error is detected on the
                              interface card.

     Hewlett-Packard               - 2 -             (printed 7/16/86)

     CONNECT(2)               Series 300 Only               CONNECT(2)

     RETURN VALUE
          If the connection or binding succeeds, then 0 is returned.
          Otherwise a -1 is returned, and a more specific error code
          is stored in errno.

     SEE ALSO
          accept(2), select(2), socket(2), getsockname(2), socket(4)

     Hewlett-Packard               - 3 -             (printed 7/16/86)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026