int connect(int sockfd, const struct sockaddr *addr, unsigned int addrlen);
This syscall connects the passed socket to the passed global address.
If the passed socket is datagram-based, then addr
is the address to
which datagrams are sent by default, and the only address from which datagrams
are received. If the socket is stream-based, the syscall attempts to make a
connection to the socket that is bound to the address specified by addr
.
The syscall returns 0
on success or -1
on failure, with the
following errno:
EINVAL
: Invalid address, may not be bound.
EFAULT
: Bad memory address.
EBADFD
: The passed FD is not a socket.