Client-server model

Different models are used for IPC, but the most popular one is the client-server model. In this model, whenever the client needs some information, it connects to another process called the server. But before establishing the connection, the client needs to know whether the server already exists, and it should know the address of the server.

On the other hand, the server is meant to serve the needs of the client and does not need to know the address of the client prior to the connection. To establish a connection, a basic construct called a socket is required, and both the connecting processes must establish their own sockets. The client and the server need to follow certain procedures to establish their sockets.

To establish a socket on the client side, a socket is created with the socket function system call. Thereafter, that socket is connected to the server's address using the connect function system call, followed by sending and receiving data by invoking the read function and write function system calls.

To establish a socket on the server side, again, a socket is created with the socket function system call and then the socket is bonded to an address using the bind function system call. Thereafter, the listen function system call is invoked to listen for the connections. Finally, the connection is accepted by invoking the accept function system call.