Skip to main content

My reference implementation of a terminal-based chat program using sockets; supports both client and server modes.

Project description

PyTermTalk-Ref 🖥️💬

Python License

A Python reference implementation of a terminal-based chat program using sockets. Supports both server and client modes. This project serves as a starting point for building a production-ready terminal chat application.

⚠️ Warning: This script does not provide authentication. Do not use it for production or sensitive purposes.

The original script by Andrea Ciarrocchi was published in Linux Magazine, October 2025.


Features

  • Terminal-based chat via sockets
  • Non-blocking communication using threads
  • Supports multiple clients simultaneously
  • Easy to extend and modify for educational purposes

Installation & running from PyPi

mkdir testing && cd testing
python -m venv .venv
source .venv/bin/activate
pip install pytermtalk-ref

# and now run the script ...

python pytermtall-ref

# when finished, deactivate the venv:

deactivate

Installation & running from PyPi with uv

When using the uv tool:

mkdir testing && cd testing
uv init
uv add pytermtalk-ref

# and now run the script ...

uv run pytermtalk-ref

Installation & running from github

When using the uv tool:

git clone https://github.com/rikroos/pytermtalk-ref.git
cd pytermtalk-ref
uv run pytermtalk-ref

Otherwise, if not using the uv tool:

git clone https://github.com/rikroos/pytermtalk-ref.git
cd pytermtalk-ref
python src/pytermtalk_ref/chat.py

Usage

On startup, choose between server or client mode.

Server Mode

  • Initializes a socket (127.0.0.1:5555)
  • Starts listening for client connections
  • Launches a thread for non-blocking broadcasting to all connected clients
  • For each new client, a separate thread is created to handle communication

Client Mode

  • Initializes a socket (127.0.0.1:5555)
  • Launches a thread to receive messages from the server non-blocking
  • Messages may come from other clients or the server operator
  • Client can send messages to other clients via the server

Future Work

  • None, the project serves as a reference implementation for other projects

Example

# Start server
$ uv run pytermtalk-ref

Warning: do not use in production environments or for exchanging sensitive information!

Start server or client? (s/c): s
[LISTENING] Server is listening on 127.0.0.1:5555
[NEW CONNECTION] ('127.0.0.1', 33076) connected.
('127.0.0.1', 33076): Hi there. Anybody home?

# Start client
$ uv run pytermtalk-ref

Warning: do not use in production environments or for exchanging sensitive information!

Start server or client? (s/c): c
Hi there. Anybody home?

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytermtalk_ref-1.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytermtalk_ref-1.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pytermtalk_ref-1.1.1.tar.gz.

File metadata

  • Download URL: pytermtalk_ref-1.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for pytermtalk_ref-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9a9efc0ca4859f7de2036fa1fca3b0e9c753be28c36fdee62196895702510863
MD5 cd5178e032b60bebe0da85bdd315d60b
BLAKE2b-256 c36a9742ec6571ca1e6de3c9e8540613be5103d48e97e46efa4e30db2c32852d

See more details on using hashes here.

File details

Details for the file pytermtalk_ref-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytermtalk_ref-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 49dfeaf7ecbf7f1026d8aed6c05fffd5e7b691bf0f2f42c52bb0c71aeaf616e0
MD5 2375f7a15c8166e6762281349d8d32c6
BLAKE2b-256 7120c813e630847d5d7229d7df1aac13d049a606fe98534aff3212c2eb2d2924

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page