Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ connect(2) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

accept

getsockname

select

socket



CONNECT(2,L)                AIX Technical Reference                CONNECT(2,L)



-------------------------------------------------------------------------------
connect



PURPOSE

Initiates a connection on a socket.

SYNTAX

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

int connect (s, name, namelen)
int s;
struct sockaddr *name;
int namelen;

DESCRIPTION

The parameter s is a socket.  If it is of type SOCK_DGRAM, this system call
specifies the peer with which the socket is to be associated.  Datagrams are to
be sent to this address, and it is the only address from which datagrams are to
be received.

If the socket is of type SOCK_STREAM, this system call attempts to make a
connection to another socket.  The other socket is specified by name, which is
an address in the communication space of the socket.  Each communication space
interprets the name parameter in its own way.

Generally, stream sockets may successfully connect only once; datagram sockets
may use connect multiple times to change their association.  Datagram sockets
may dissolve the association by connecting to an invalid address, such as a
null address.

RETURN VALUE

Upon successful completion, a value of 0 is returned.  If the connect system
call fails, a value of -1 is returned, and errno is set to indicate the error.

ERROR CONDITIONS

The connect system call fails if one or more of the following are true:

EBADF          The s parameter is not valid.

ENOTSOCK       The s parameter refers to a file, not a socket.

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





Processed November 7, 1990       CONNECT(2,L)                                 1





CONNECT(2,L)                AIX Technical Reference                CONNECT(2,L)



EAFNOSUPPORT   The addresses in the specified address family cannot be used
               with this socket.

EISCONN        The socket is already connected.

ETIMEDOUT      The establishment of a connection timed out before a connection
               was made.

ECONNREFUSED   The attempt to connect was rejected.

ENETUNREACH    The network is not reachable from this host.

EADDRINUSE     The specified address is already in use.

EFAULT         The addr parameter is not in a writable part of the user address
               space.

EINPROGRESS    The socket is marked nonblocking and the connection cannot be
               completed immediately.  Using the select system call, completion
               can be determined by selecting the socket for writing.

EALREADY       The socket is marked nonblocking and a previous connection
               attempt has not yet completed.

The following errors are specific to connecting names in the AF_UNIX address
family.

ENAMETOOLONG
          A component of the path name exceeded NAME_MAX characters, or the
          entire path name exceeded PATH_MAX characters.

ENOTDIR   A component of the path name is not a directory.

EINVAL    The path name contains a character with the high-order bit set.

ENOENT    The named socket does not exist.

ELOOP     A loop of symbolic links was detected.

EACCES    Search permission is denied for a component of the path prefix.

EACCES    Write access to the named socket is denied.

RELATED INFORMATION

In this book:  "accept," "getsockname," "select," and "socket."









Processed November 7, 1990       CONNECT(2,L)                                 2



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