Go to the previous, next section.

connect

SYNOPSIS

int connect(int sockfd, struct sockaddr *serv_addr, int addrlen);

PARAMETERS

sockfd: [in] the socket to connect.

serv_addr: [in] the remote address to connect to.

addrlen: [in] the lenght (in bytes) of serv_addr.

DESCRIPTION

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.

RETURN VALUE

On success zero is returned. On error, -1 is returned and errno is set to one of the following values:

Go to the previous, next section.