Loading repository data…
Loading repository data…
SagarBiswas-MultiHAT / repository
TCP-Playground; A simple multi-client TCP, compact, cross‑platform Python multi‑client chat toolkit for learning and LAN testing. Includes host.py (server), clint.py (client), and net_utils.py utilities; supports optional TLS with password‑protected message encryption, CLI flags for scripted use, and unit tests for core validation.
A simple multi-client TCP chat app in Python, built for learning and practical local/LAN testing.
This project gives you:
host.py)clint.py)Note: the client file is intentionally named
clint.py.
host.py starts a chat server.clint.py connects clients to that server.--cert--tls-insecure (local testing only)When secure mode is ON:
When secure mode is OFF:
Open one terminal for server and one or more for clients.
python -u host.py
python -u clint.py
The client will prompt for:
Run python -u clint.py again in additional terminals and use different names.
Generate cert (OpenSSL with addext; recent OpenSSL versions):
openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 365 `
-subj "/C=BD/ST=Dhaka/L=Dhaka/O=MultiHAT/OU=RedHAT/CN=localhost" `
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
Start the host:
python -u host.py --port 12345 --secure --password mypass --tls --cert cert.pem --key key.pem
Connect the client (trust the cert):
python -u clint.py --host 127.0.0.1 --port 12345 --tls --cert cert.pem
If you only want quick local testing and do not want certificate verification:
python -u clint.py --host 127.0.0.1 --port 12345 --tls --tls-insecure
host.py)python -u host.py --bind 0.0.0.0 --port 12345 --timeout 0
Options:
--bind bind address (default: all interfaces)--port TCP port--timeout socket timeout in seconds (0 = blocking)--secure enable secure mode without prompt--password set secure password non-interactively--tls enable TLS--cert certificate PEM file--key private key PEM fileclint.py)python -u clint.py --host 127.0.0.1 --port 12345
Options:
--host server host/IP--port server port--timeout socket timeout--name client display name (if omitted, prompt asks)--password secure-mode password (if omitted, prompt asks)--tls force TLS first--cert certificate/CA PEM to trust during TLS verification--tls-insecure disable certificate verification (testing only)Server:
Listening on 127.0.0.1:12345... (Ctrl-C to stop)
Security mode: ENCRYPTED
Connection from 127.0.0.1:56582
Alice joined from 127.0.0.1:56582
+ Total connected clints: [1]
..:: Alice[56582]: Hello everyone
Client:
--> Enter the IP address of the server: 127.0.0.1
--> Enter the port you want to connect to: 12345
--> Enter your user name: Alice
--> Enter password:
Authenticated as Alice
Connected to 127.0.0.1:12345
Install test dependency:
pip install -r requirements.txt
Run tests:
pytest -q
Current tests cover shared utilities in net_utils.py:
Workflow file:
.github/workflows/python-ci.ymlIt runs on push and pull request against Python:
3.93.103.113.12To maximize chance of green tick in Get started with GitHub Actions:
pytest -q)..github/workflows/python-ci.yml in place.host.py
clint.py
net_utils.py
tests/
.github/workflows/python-ci.yml
TLS certificate verification failed on client
--cert cert.pem, or for local tests only use --tls-insecure.tlsv1 alert unknown ca / bad certificate on server logs
This project is intentionally lightweight and easy to read. If you want, the next natural improvements are:
/help, /users, /rename)