SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int connect(int s, const struct sockaddr *name, socklen_t namelen);
DESCRIPTION
The
The
For stream sockets (type SOCK_STREAM), an active connection is initiated to the foreign host using name (an address in the name space of the socket). When the socket call completes successfully, the socket is ready to send/receive data.
For a datagram socket (type SOCK_DGRAM), a default destination
is set, which is used on subsequent
If the connection cannot be established immediately and O_NONBLOCK
is not set for the file descriptor for the socket,
If the connection cannot be established immediately and O_NONBLOCK
is set for the file descriptor for the socket,
When the connection has been established asynchronously,
PARAMETERS
- s
-
Specifies the integer descriptor of the socket to be connected.
- name
-
Points to a sockaddr structure containing the peer address. The length and format of the address depend on the address family of the socket.
- namelen
-
Specifies the length of the sockaddr structure pointed to by name argument.
RETURN VALUES
If successful,
- EADDRINUSE
-
The specified address is already in use.
- EADDRNOTAVAIL
-
The specified address is unavailable on the remote machine or the address field of the name structure is all zeroes.
- EAFNOSUPPORT
-
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
-
s is not a valid descriptor.
- ECONNREFUSED
-
The attempt to connect was forcefully rejected.
- ECONNRESET
-
The remote host reset the connection request.
- EDESTADDREQ
-
A destination address is required.
- EFAULT
-
name is an invalid pointer.
- EHOSTUNREACH
-
The destination host cannot be reached.
- EINPROGRESS
-
The socket is marked as non-blocking and the connection cannot be completed immediately. The connection is established asynchronously.
- EINTR
-
A signal interrupted the call. The connection is established asynchronously.
- EINVAL
-
The namelen argument is not a valid length for the address family, or the sockaddr structure contains an invalid address family.
- EISCONN
-
The socket is already connected.
- EMFILE
-
No more file descriptors are available.
- ENETDOWN
-
The network subsystem has failed.
- ENETUNREACH
-
The network is unreachable from this host at this time.
- ENOBUFS
-
No buffer space is available. The socket cannot be connected.
- ENOTSOCK
-
s is not a socket.
- EOPNOTSUPP
-
The socket is listening and cannot be connected.
- ETIMEDOUT
-
The attempt to connect timed out without establishing a connection.
CONFORMANCE
UNIX 98, with exceptions.
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
The NuTCRACKER Platform supports all the address families that WinSock 2.0 supports.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
PTC MKS Toolkit 10.4 Documentation Build 39.