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