NAME connect - initiate a connection on a socket SYNOPSIS #include #include int connect(int sockfd, struct sockaddr *serv_addr, int addrlen ); DESCRIPTION The parameter sockfd is a socket. If it is of type SOCK_DGRAM, this call specifies the peer with which the socket is to be associated; this address is that to which datagrams are to be sent, and the only address from which datagrams are to be received. If the socket is of type SOCK_STREAM , this call attempts to make a connection to another socket. The other socket is specified by serv_addr, which is an address in the communications space of the socket. Each communications space interprets the serv_addr, parameter in its own way. Generally, stream sockets may successfully connect only once; datagram sock- ets may use connect multiple times to change their associ- ation. Datagram sockets may dissolve the association by connecting to an invalid address, such as a null address. RETURN VALUE If the connection or binding succeeds, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS See the Linux kernel source code for details. HISTORY The connect function call first appeared in BSD 4.2. SEE ALSO accept(2), bind(2), listen(2), socket(2), getsockname(2)