A complete implementation of Client-Server Communication using Python's built-in
socketlibrary — covering both TCP and UDP protocols with real-time bidirectional messaging.
This project demonstrates real-time Client-Server Communication using Python sockets. It implements both TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) with features like timestamps, uppercase conversion, message counting, and graceful exit handling.
Socket-Programming-Python/
│
├── tcp_server.py # TCP Server Program
├── tcp_client.py # TCP Client Program
├── udp_server.py # UDP Server Program
├── udp_client.py # UDP Client Program
└── README.md # Project Documentation
- ✅ TCP Client-Server Communication
- ✅ UDP Client-Server Communication
- ✅ Student Name & Registration Number on startup
- ✅ Timestamp on every message
[HH:MM:SS] - ✅ Messages automatically converted to UPPERCASE
- ✅ Message counter (tracks total messages sent)
- ✅ Type
exitto gracefully end the session
| Feature | TCP | UDP |
|---|---|---|
| Connection | Required | Not Required |
| Reliability | High ✅ | Low |
| Speed | Slower | Faster ⚡ |
| Data Order | Guaranteed | Not Guaranteed |
| Port Used | 12345 |
12346 |
| Real-world Use | HTTP, FTP, Email | Streaming, Gaming, DNS |
python --version # Make sure Python 3.x is installedOpen two terminals simultaneously:
# Terminal 1 — Run Server FIRST
python tcp_server.py
# Terminal 2 — Run Client SECOND
python tcp_client.py# Terminal 1 — Run Server FIRST
python udp_server.py
# Terminal 2 — Run Client SECOND
python udp_client.py
⚠️ Always start the Server before the Client!
========================================
UDP SERVER STARTED
Student : Niha Hawas
========================================
Listening on 127.0.0.1:12346 ...
Waiting for messages...
[20:24:28] Client [1]: HELLO
└ UPPERCASE: [NIHA HAWAS | 2312274] CLIENT: HELLO
Your Reply: HI
[20:24:46] Client [2]: HAVE YOU DONE YOUR TASK
└ UPPERCASE: CLIENT: HAVE YOU DONE YOUR TASK
Your Reply: YES IT IS DONE
✅ UDP Server closed. Total messages handled: 7
| # | Task | Status |
|---|---|---|
| 1 | TCP Server and Client communication | ✅ |
| 2 | UDP Server and Client communication | ✅ |
| 3 | Exchange at least 5 messages | ✅ (7 messages) |
| 4 | Send Student Name and Registration Number | ✅ |
| ⭐ | Timestamps on every message | ✅ |
| ⭐ | Convert messages to UPPERCASE | ✅ |
| ⭐ | Terminate session with exit command |
✅ |
| Tool | Purpose |
|---|---|
| Python 3.x | Core Language |
socket module |
Network Communication |
| VS Code | Development Environment |
| GitHub | Version Control |
- Client-Server Architecture
- TCP — Connection-Oriented Communication
- UDP — Connectionless Communication
- Socket Binding, Listening & Accepting
- Real-time Bidirectional Messaging
- Data Encoding & Decoding over Sockets
|
Niha Hawas |
This project is licensed under the MIT License — feel free to use and modify.
Made with ❤️ by Niha Hawas