Go to the previous, next section.
int connect(int sockfd, struct sockaddr *serv_addr, int
addrlen);
sockfd: [in] the socket to connect.
serv_addr: [in] the remote address to connect to.
addrlen: [in] the lenght (in bytes) of serv_addr.
If the socket is of type SOCK_DGRAM
, it connects the socket
sockfd to a remote address specified by serv_addr. A
datagram socket can call connect
multiple times to change the
remote address. If the socket is of type SOCK_STREAM
, it connects
the socket to another socket. In that case, the format of
serv_addr depends on the communication space of the socket. A
stream socket may only call connect
once.
On success zero is returned. On error, -1 is returned and errno
is
set to one of the following values:
EINVAL
: the socket is in some kind of limbo state: neither
connected nor unconnected!!!
EBADF
, ENOTSOCK
, EISCONN
, EALREADY
,
EAGAIN
, EOPNOTSUPP
, EINPROGRESS
, ERESTARTSYS
.
Go to the previous, next section.