Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2025-12-30
Problem Statement
Design and implement a simplified networking module that demonstrates fundamental networking concepts such as client-server communication, request-response handling, and data transmission over sockets.
The goal is to help you understand how network protocols, connections, and data flow operate at a low level, using object-oriented design principles.
📋 Problem Description
You are required to design a mini client-server system where:
•A Server listens for incoming client connections,
•A Client connects to the server, sends a request,
•The Server processes it and sends back a response.
This problem focuses on the LLD of networking concepts, not on real-world distributed scalability — but you should still think in terms of extensible design and clean abstraction.
🧱 Core Requirements
1. Classes to Design
•Server — Listens for incoming connections, handles requests.
•Client — Connects to the server and sends requests.
•Request — Represents data being sent from client to server.
•Response — Represents server’s reply to the client.
•Connection (optional) — Manages socket-like connection objects between clients and the server.
⚙️ Functional Requirements
1.Client Operations
•Establish a connection with the server.
•Send a request (e.g., a message or command).
•Receive and display the response from the server.
2.Server Operations
•Listen on a port for incoming client connections.
•Accept requests and log them.
•Generate appropriate responses (e.g., echo the message or perform a small computation).
•Handle multiple clients sequentially (or concurrently if extended).
3.Communication Protocol
•Use a simple text-based or JSON-based message format: