Computer Network - Client Server Model

Client Server Model (Full Explanation)

Client Server Model

Two remote application processes can communicate primarily in two distinct ways:

  • Peer-to-peer: Both remote processes operate at the same level and share data through a common resource.
  • Client-Server: One remote process functions as a Client, requesting resources from another application process that serves as the Server.

In the client-server model, any process can take on the role of Server or Client. It is not determined by the type, size, or computing power of the machine that defines it as a server; rather, it is the capability to fulfill requests that qualifies a machine as a server.

A system can simultaneously function as both Server and Client. This means one process can serve as the Server while another acts as the Client. It is also possible for both the client and server processes to exist on the same machine.

Communication

Two processes within the client-server model can engage in various forms of interaction:

  • Sockets
  • Remote Procedure Calls (RPC)

Sockets

In this framework, the process designated as Server opens a socket on a well-known port (or one known to the client) and waits for incoming client requests. Conversely, the Client process also opens a socket but takes the initiative to send requests rather than waiting for a response.

Sockets Diagram


Once the request reaches the server, it is processed. This can involve either sharing information or fulfilling a resource request.

Remote Procedure Call

This mechanism allows one process to interact with another through procedure calls. The Client process invokes a procedure located on a remote host, which is referred to as the Server. Both processes are assigned stubs, and the communication unfolds in the following manner:

  • The client process invokes the client stub, transmitting all parameters relevant to its local program.
  • These parameters are subsequently packed (marshalled) before a system call is initiated to transmit them across the network.
  • The kernel transfers the data over the network, where it is received by the other end.
  • The remote host forwards the data to the server stub, where it undergoes unmarshalling.
  • The parameters are then relayed to the procedure, which is executed accordingly.
  • Finally, the result is returned to the client using the same process.