Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
What is a client-server system?
A client-server system is a distributed computing architecture where multiple clients request services from centralized servers over a network. Communication in client-server systems can utilize shared memory and message passing techniques, along with several specialized communication strategies.
Strategies for Communication
There are three primary strategies for communication in client-server systems −
Sockets
A socket is defined as an endpoint for communication. A pair of processes communicating over a network employs a pair of sockets, one for each process. A socket is identified by an IP address concatenated with a port number.
Sockets generally use client-server architecture. The server waits for incoming client requests by listening to a specified port. Once a request is received, the server accepts a connection from the client to complete the communication.
Example
When a client process initiates a request for a connection, it is assigned a port by its host computer. This port has an arbitrary number greater than 1024. If a client on HOST S with IP address 126.48.5.30 wants to establish a connection with a web server at address 142.30.45.8, HOST S may be assigned port 1465.
The connection will consist of a pair of sockets: 126.48.5.30:1465 on HOST S and 142.30.45.8:80 on the web server.
Remote Procedure Call (RPC)
RPC is one of the most common forms of remote service communication. The RPC was designed as a way to abstract the procedure call mechanism for use between systems with network connections. It is similar in many aspects to the IPC mechanism and is usually built on top of such a system.
However, since we are dealing with an environment where processes are executing on separate systems, we must use a message-based communication schema to provide remote service. RPC allows a program to call a procedure on a remote machine as if it were a local procedure call.
Pipes
A pipe acts as a conduit that allows two processes to communicate. Pipes are one of the first IPC mechanisms in early UNIX systems. They provide one of the simpler ways for processes to communicate with one another, although they have some limitations.
There are two types of pipes used on both UNIX and Windows systems −
Ordinary pipes
Named pipes
Ordinary Pipes
Ordinary pipes allow two processes to communicate in standard producer-consumer fashion. The producer writes to one end of the pipe and the consumer reads from the other end. As a result, ordinary pipes are unidirectional, allowing only one-way communication.
An ordinary pipe cannot be accessed from outside the process that creates it. Typically, a parent process creates a pipe and uses it to communicate with a child process created through fork().
Named Pipes
Ordinary pipes provide a simple mechanism for allowing a pair of processes to communicate. However, ordinary pipes exist only while the processes are communicating with one another. Once the processes finish communicating and terminate, the ordinary pipe ceases to exist.
Named pipes provide a more powerful communication tool. Communication can be bidirectional and no parent-child relationship is required. Once a named pipe is established, several processes can use it for communication, and it persists beyond the lifetime of the creating process.
Comparison
| Communication Method | Direction | Network Support | Persistence |
|---|---|---|---|
| Sockets | Bidirectional | Yes | Connection-based |
| RPC | Bidirectional | Yes | Call-based |
| Ordinary Pipes | Unidirectional | No | Process lifetime |
| Named Pipes | Bidirectional | Limited | Beyond process lifetime |
Conclusion
Client-server communication relies on various mechanisms including sockets, RPC, and pipes. Sockets provide network-based communication, RPC abstracts remote procedure calls, while pipes offer local inter-process communication. The choice depends on whether communication is local or networked, and the required features like bidirectionality and persistence.
