This project is the Minimum Viable Product (MVP) for a university computer science club initiative focused on understanding network communication fundamentals. It implements a basic, single-threaded TCP Client-Server model using Python's built-in socket module.
The primary objective is to demonstrate the TCP Three-Way Handshake and reliable data transfer (send/receive) between two separate processes running on the local machine (localhost).
- Language: Python 3.x
- Networking: TCP/IP Sockets (via Python's
socketmodule) - Design: Client-Server Model (Point-to-Point)
Implements the client role:
- Connects to the server
- Sends data
- Receives an acknowledgment (ACK)
- Closes the connection
Implements the server role:
- Binds to a host and port
- Listens for incoming connections
- Accepts a client connection
- Receives data from the client
- Sends a response
- Closes the connection
- Python 3.x: Ensure Python 3 is installed and accessible via your terminal.
python3 --version
The server must be started before the client can attempt a connection. This project is configured for a single, sequential communication session.
-
Start the Server (Terminal 1): Open one terminal window and execute the server script. The server will enter a blocking state, waiting at the
s.accept()call.python3 server.py
Expected Status: Server outputs "Server initializing..." and pauses.
-
Run the Client (Terminal 2): Open a second, separate terminal window and execute the client script.
python3 client.py
Expected Status: Client connects, sends data, receives acknowledgement, and both client and server processes terminate.
- Protocol: Uses TCP (stream sockets) for guaranteed delivery.
- Host/Port: Configured for
127.0.0.1:8888(localhost). - Lifecycle: The
server.pyscript is designed to handle one single client connection and then shut down immediately, satisfying the initial MVP requirement. - Data Handling: All data is handled as bytes and uses
encode('utf-8')anddecode('utf-8')for string readability.