NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUE | ATTRIBUTES | SEE ALSO
#include <sys/types.h> #include <sys/socket.h>int connect(int s, const struct sockaddr *name, int namelen);
POSIX_SOCKETS
The s parameter is a socket. If it is of the type SOCK_DGRAM, this call specifies the peer with which the socket is to be associated. Datagrams must be sent to this address; it is also the only address from which datagrams may be sent. If the socket is of the type SOCK_STREAM, this 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.
Upon successful completion, connect returns 0; otherwise it returns -1 and sets errno to indicate one of the following error conditions:
The s argument is not a valid descriptor.
The s argument is a descriptor for a file, not a socket.
The specified address is not available on this machine.
Addresses in the address family specified cannot be used with this socket.
The socket is already connected.
Connection establishment timed out without establishing a connection.
The attempt to connect was forcefully rejected.
The network isn't reachable from this host.
The address is already in use.
The name parameter specifies an area outside the c_actor's address space.
The socket is non-blocking and the connection cannot be completed immediately. It is possible to select(2POSIX) for completion by selecting the socket for writing.
The socket is non-blocking and a previous connection attempt has not yet been completed.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUE | ATTRIBUTES | SEE ALSO