Skip to content

Veltix

The high-level TCP library Python never had.

Lines of code PyPI Python License Downloads

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

@server.route(CHAT)
def on_chat(client: ClientInfo, response: Response):
    print(f"{client.addr}: {response.content.decode()}")

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

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 send 52,109 msg/s 52,296 msg/s
Average latency 0.032 ms 0.035 ms
Idle server memory 46 KB 4 KB

Full details : Performance