1.1.27.8 connect

C

int connect(int fd, const struct sockaddr *addr, socklen_t len)

Description

Initiate a connection on a socket.

Parameters

ParametersDescription
fdSocket file descriptor.
addrPointer to socket address.
lenLength of socket address.

Returns

  • 0 - Success.
  • -1 - Error, errno set.

Remarks

errnoDescription
EFAULTSystem fault.
ENOTSOCKThe file descriptor fd does not refer to a socket.
EAFNOSUPPORTThe implementation does not support the specified address family.
EAGAINThe socket is nonblocking, and the connection cannot be completed immediately.
ENOMEMInsufficient memory is available.
EBADMSGBad message.
EINPROGRESSThe socket is nonblocking and the connection cannot be completed immediately.It is possible to poll for completion by selecting the socket for writing. After poll indicates writability.
EISCONNThe socket is already connected.