Client-Server Architecture | Cyber Security Tutorial - Learn with VOKS
Back Next

Client-Server Architecture


Client-Server Architecture

Client-Server Architecture is a fundamental model used in networking and web systems. It explains how different computers communicate and share resources.

What Is Client-Server Architecture

Client-Server Architecture is a system where:

  • A Client requests services or resources.
  • A Server provides those services or resources.

The client and server are separate systems connected over a network.

Simple idea:

Client → Sends Request

Server → Sends Response

What Is A Client

A Client is a device or program that requests data or services.

Examples of clients:

  • Web browsers (Chrome, Firefox)
  • Mobile apps
  • Desktop applications
  • ATM machines
  • Email applications

The client initiates communication.

What Is A Server

A Server is a computer or program that:

  • Listens for requests
  • Processes them
  • Sends back responses

Servers are usually powerful computers that run continuously.

Examples of servers:

  • Web servers
  • Database servers
  • File servers
  • Mail servers

Basic Communication Flow

Here is the general process:

Step 1: Client sends a request.

Step 2: Server receives the request.

Step 3: Server processes the request.

Step 4: Server sends a response.

Step 5: Client displays or uses the response.

Example in web browsing:

You type a website URL.

Browser (client) sends request.

Web server sends back HTML page.

Browser displays it.

Real-World Analogy

Think of a restaurant.

Customer → Client

Waiter → Network

Kitchen → Server

Customer orders food.

Kitchen prepares food.

Food is delivered back to customer.

The kitchen does not ask customers for orders.

The customer starts the interaction.

Types Of Client-Server Systems

Two-Tier Architecture

Client communicates directly with server.

Example:

Browser ↔ Web Server

Three-Tier Architecture

Client → Application Server → Database Server

Example:

Browser → Backend Server → Database

This is common in modern web applications.

Advantages Of Client-Server Architecture

Centralized Control

Data is stored on the server.

Security

Server can control access and permissions.

Scalability

Servers can be upgraded to handle more clients.

Maintenance

Updates are done on the server, not every client.

Disadvantages Of Client-Server Architecture

Server Dependency

If server fails, clients cannot access services.

Network Dependency

Requires stable network connection.

Cost

Servers and infrastructure can be expensive.

Example Of Client-Server Communication Using Python

Below is a simple example of a server and a client using Python sockets.

Server Code:


import socket

server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(("localhost", 5000))
server_socket.listen(1)

print("Server is listening...")

conn, addr = server_socket.accept()
print("Connected by", addr)

data = conn.recv(1024)
print("Received:", data.decode())

conn.sendall(b"Hello from server")
conn.close()

Client Code:


import socket

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", 5000))

client_socket.sendall(b"Hello from client")
data = client_socket.recv(1024)

print("Received:", data.decode())
client_socket.close()

How It Works:

  1. Server starts and listens on port 5000.
  2. Client connects to server.
  3. Client sends a message.
  4. Server receives message and replies.
  5. Client receives reply.

This demonstrates the basic client-server model.

Common Protocols Used In Client-Server Architecture

HTTP

Used for web communication.

FTP

Used for file transfer.

SMTP

Used for sending emails.

DNS

Used for domain name resolution.

All these follow the client-server model.

Stateless Vs Stateful Servers

Stateless Server

Does not remember previous requests.

Example:

HTTP is mostly stateless.

Stateful Server

Remembers client information between requests.

Example:

Online games, database sessions.

Modern Client-Server Example

When you log into a social media platform:

Client:

Your browser or app sends login details.

Server:

Authenticates credentials.

Checks database.

Returns success or failure.

Stores session.

All major websites use client-server architecture.

Client-Server Vs Peer-To-Peer

Client-Server:

Central server handles requests.

Peer-To-Peer:

Each computer can act as both client and server.

Example of peer-to-peer:

File sharing networks.

Client-server is more common for web applications.

Example Code:
# Server Code
import socket

server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(("localhost", 5000))
server_socket.listen(1)

print("Server is listening...")

conn, addr = server_socket.accept()
print("Connected by", addr)

data = conn.recv(1024)
print("Received:", data.decode())

conn.sendall(b"Hello from server")
conn.close()

# Client Code
import socket

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", 5000))

client_socket.sendall(b"Hello from client")
data = client_socket.recv(1024)

print("Received:", data.decode())
client_socket.close()
Cyber Security
Introduction Types of Cyber Threats Cyber Security Domains CIA Triad (Confidentiality Integrity Availability) Career paths in Cyber Security Certifications Ethics and Responsible Disclosure Laws and Regulation (e.g. GDPR, NDPR) What is an OS? Types: Window, Linus, macOS Command-line vs GUI OS Internals Overview (filesystems, processes, permissions) Windows command prompt basics Linux Bash Basics File System Navigation Basic Scripting IP Addressing DNS, DHCP Mac Address OSI VS TCP/IP Models Ports and Protocols (TCP, UDP) Common Protocols (HTTPS, FTP, SSH, etc.) Packet structure Firewalls, IDS/IPS, VPNs Common attacks: MITM, Sniffing Secure Network Practices How the Web works HTTP vs HTTPS URLs, Headers, Cookies Client-Server Architecture Introduction To Web Security OWASP Top 10 Overview Common Threats (XSS, SQLi, CSRF) Inpute validation and authentication flow Basic Exploitation demo (e.g. XSS) Burp Suite Introduction Using a Browser For Testing Password security MFA-Antivirus Cyber Hygeine Practice Intro To Tools: Nmap, Wireshark, Netstat
All Courses
Advance AI Bootstrap C C++ Computer Vision Content Writing CSS Cyber Security Data Analysis Deep Learning Email Marketing Excel Figma HTML Java Script Machine Learning MySQLi Node JS PHP Power Bi Python Python for AI Python for Analysis React React Native SEO SMM SQL