|
|
Once a process has bound a local socket, the process can rendezvous with an unrelated foreign process. 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. Using the UNIX domain, this might appear as,
struct sockaddr_un server; ... connect(s, (struct sockaddr *)&server, strlen(server.sun_path) + sizeof (server.sun_family));where server would contain the UNIX pathname of the server to which the client process wishes to speak. If the socket of the client process 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 (UNIX domain)'' for the list of errors.
The connect call is only used by active processes. 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.