|
|
Once a process has bound a local socket, the process can
rendezvous with an unrelated foreign process (a process
initiated by a remote source).
Usually, the rendezvous takes the form of a client-server relationship.
The client completes the other side of the socket pair when
it requests services from the server, initiating a connection
by issuing a connect call:
struct sockaddr_in server;
connect(s, (struct sockaddr *) &server, sizeof (server));
server is the Internet address and port number of the server to which the client is connecting. If the client process's socket is unbound when it issues the connect call, the system automatically selects a name and binds the socket. If the socket is successfully associated with the server, data transfer can begin. If not, an error is returned. See ``Connection errors (Internet domain)'' for the list of errors.
Only the active process uses connect. An active process is a process that initiates a connection; a passive process, such as a server process, listens for calls and accepts them, but does not initiate them.