Skip to main content

The high-level TCP library Python never had — sync, thread-friendly, zero dependencies

Project description

Veltix

The high-level TCP library Python never had.

Lines of code PyPI Python License Downloads Security Policy

Sync, thread-friendly, zero dependencies : TCP done right.
Veltix handles framing, threading, handshake, routing, and reconnection
so you can focus on your application logic.

77k msg/s0.032ms latency46KB idle2x stress throughput100% success rate


Table of Contents


Built with Veltix

Projects using Veltix in production:

  • Nexo : Fast LAN file transfer tool CLI + GUI. Uses Veltix's TCP server, client tags, route decorators, and send_and_wait() for reliable chunked file transfers with concurrent connection handling.

Built something with Veltix ? Open a PR or start a discussion to add your project.


Why Veltix

Python's socket module is powerful but painful. You end up reimplementing framing, threading, reconnection, and protocol design every single time. Heavier alternatives like asyncio or Twisted solve this but force you into async/await or steep learning curves.

Veltix sits in between:

  • No async required : sync, thread-based, works like you expect
  • No boilerplate : framing, handshake, routing, reconnect are built-in
  • No dependencies : pure Python stdlib, zero install friction
  • FastAPI-style routing : @server.route(MY_TYPE) instead of if/elif chains
# This is all you need to get a working server
@server.route(CHAT)
def on_chat(response: Response, client: ClientInfo):
    print(f"{client.addr}: {response.content.decode()}")

Designed for: LAN tools, multiplayer games, real-time dashboards, custom protocols, IPC, remote tooling, file transfer.


Features

Core

  • Zero dependencies : pure Python stdlib
  • Binary protocol with CRC32 integrity verification
  • Automatic HELLO/HELLO_ACK handshake with version compatibility
  • Thread-safe callback execution : slow handlers never block reception

API

  • FastAPI-style routing : @server.route(MY_TYPE) / @client.route(MY_TYPE)
  • send_and_wait() : built-in request/response correlation with timeout
  • Built-in ping/pong : bidirectional latency measurement
  • Client tags : attach arbitrary metadata to connected clients

Reliability

  • Auto-reconnect : configurable retry with DisconnectState callbacks
  • SMALL / MEDIUM / LARGE buffer size presets
  • Swappable socket backends via SocketCore (Threading or Async/Selectors, Rust in v3.0.0)

Developer Experience

  • Integrated logger : colorized, file-rotating, thread-safe
  • 261 tests, CI on Python 3.8 / 3.10 / 3.12 / 3.14

Performance

Benchmarked on Python 3.14.5 — 12-core CPU, 30.5 GB RAM, Linux (loopback).

Metric Threading Async
Concurrent stress (100 clients) 37,676 msg/s 76,929 msg/s
Burst throughput 52,109 / 41,327 52,296 / 41,343
Average latency 0.032 ms 0.035 ms
Idle server memory 46 KB 4 KB
Per client memory (avg) 36 KB 12 KB
FPS simulation (64 players @ 64Hz) 4,488 msg/s 4,488 msg/s

Full benchmark details, methodology, and how to run them yourself : PERFORMANCE.md

Installation

pip install veltix

Requirements: Python 3.8+, no additional dependencies.


Quick Start

Server:

from veltix import Server, ServerConfig, ClientInfo, Response, MessageType, Request, Events

CHAT = MessageType(code=200, name="chat")

server = Server(ServerConfig(host="0.0.0.0", port=8080))
sender = server.get_sender()


def on_message(client: ClientInfo, response: Response):
    print(f"[{client.addr[0]}] {response.content.decode()}")
    sender.broadcast(Request(CHAT, response.content), server.get_all_clients_sockets())


server.set_callback(Events.ON_RECV, on_message)
server.start()

input("Press Enter to stop...")
server.close_all()

Client:

from veltix import Client, ClientConfig, Response, MessageType, Request, Events

CHAT = MessageType(code=200, name="chat")

client = Client(ClientConfig(server_addr="127.0.0.1", port=8080))

client.set_callback(Events.ON_RECV, lambda r: print(f"Server: {r.content.decode()}"))
client.connect()

client.get_sender().send(Request(CHAT, b"Hello Server!"))
input("Press Enter to disconnect...")
client.disconnect()
python server.py
python client.py  # In a separate terminal

Roadmap

v1.6.6 : Version Compatibility & Reconnect Stability (May 2026) : Released

Version class, reconnect stability fixes, +111 tests, CI on Python 3.8-3.14

v1.6.8 : Architecture Refactor (May 2026) : Released

ClientContext Protocol, Rules system for RequestHandler, README rewrite

v1.6.9 : Reconnect Stability & Cleanup (June 2026) : Released

8 bug fixes across reconnect path + code quality cleanups

v1.7.0 : AsyncSocket + Protocol Hardening (June 2026) : Released

AsyncSocket (selectors), MAGIC bytes, corruption recovery, benchmark averaging. 2x stress throughput, memory cut by 40-74%.

Full roadmap


Comparison

Feature Veltix socket asyncio Twisted
Simple API ~
Zero dependencies
No async required
Message framing ~
Message integrity
Automatic handshake
Request/Response ~
Message routing ~
Auto-reconnect ~
Non-blocking callbacks
Built-in ping/pong
Client tags
Swappable backends
Integrated logger ~

Documentation


Contributing

Contributions are welcome. Please read CONTRIBUTING.md before submitting a pull request.


License

MIT License : see LICENSE for details.


Links

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

veltix-1.7.0.tar.gz (69.8 kB view details)

Uploaded Source

Built Distribution

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

veltix-1.7.0-py3-none-any.whl (70.1 kB view details)

Uploaded Python 3

File details

Details for the file veltix-1.7.0.tar.gz.

File metadata

  • Download URL: veltix-1.7.0.tar.gz
  • Upload date:
  • Size: 69.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for veltix-1.7.0.tar.gz
Algorithm Hash digest
SHA256 72e4cb9e30361368f40002af280a70e2055e9bd774e235d29b28c72ddefd764f
MD5 e7be3a0511529a13802b3b2a0d62718c
BLAKE2b-256 479019bafe9617dbfdd5fec53c8c6ceb1d26964e73bfb2b1e3036f9f9e0b2001

See more details on using hashes here.

File details

Details for the file veltix-1.7.0-py3-none-any.whl.

File metadata

  • Download URL: veltix-1.7.0-py3-none-any.whl
  • Upload date:
  • Size: 70.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for veltix-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4dbd2b3c79066ae416691ca46316816641fb5a52aaafc0e45fc58500600bf63
MD5 1fcb661e14e4f6ac0394dc089c8cf0bd
BLAKE2b-256 6af278b0c9f09c992ea3683614a23c193942337736c5cd9096ac67aef8a59b12

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