Veltix does not encrypt anything
Messages travel in plaintext over TCP: anyone on the network path can read or tamper with them. Built-in encryption (TLS) is planned for the end of 2026, possibly earlier. Until then, run Veltix over a trusted network (LAN, localhost) or tunnel it yourself (WireGuard, SSH, stunnel).
Veltix¶
Python TCP, without the boilerplate.
Sync, thread-friendly, zero dependencies : TCP done right. Veltix handles framing, threading, handshake, routing, and reconnection so you can focus on your application logic.
Mature & tested : 844 tests · CI on Python 3.11-3.14 · Rust-powered hot path
Why Veltix?¶
I wrote Veltix because I got tired of rewriting the same networking boilerplate every time I needed two programs to talk to each other.
Raw sockets are powerful, but they leave framing, request routing, handshakes, reconnection, and thread management entirely up to you. asyncio solves part of the problem, but adopting it often means committing your whole application to an async architecture. Twisted is incredibly capable, but it comes with its own programming model and can feel more like learning a framework than writing plain Python.
I wanted something different: a lightweight library that handles the repetitive networking work without forcing a particular architecture. Define your message types, register your handlers, and focus on your application instead of socket plumbing.
That's the idea behind Veltix: modern TCP communication with a simple, synchronous API, sensible defaults, and zero runtime dependencies.
Raw Socket vs Veltix¶
Echo server with raw sockets (15 lines):
import socket
import threading
def handle_client(conn, addr):
while True:
data = conn.recv(1024)
if not data:
break
conn.sendall(data)
conn.close()
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(("0.0.0.0", 8080))
server.listen(5)
while True:
conn, addr = server.accept()
threading.Thread(target=handle_client, args=(conn, addr)).start()
Same thing with Veltix (7 lines):
from veltix import Server, ServerConfig, ClientInfo, Response, MessageType, Request
ECHO = MessageType("echo")
server = Server(ServerConfig(host="0.0.0.0", port=8080))
@server.route(ECHO)
def on_echo(client: ClientInfo, response: Response) -> None:
server.send(Request(ECHO, response.content), client)
server.start()
server.wait_until_closed()
No manual framing. No thread management. No boilerplate.
Features¶
Core
- Zero runtime dependencies : Python stdlib + optional Rust engine
- Rust-powered hot path : framing / parse / compile in native Rust, automatic pure-Python fallback
- Binary protocol with CRC32 integrity verification
- Automatic JSON raw-socket handshake with version compatibility
- Structured event bus : subscribe to lifecycle, message, protocol, error, and reconnect events
- 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- Text & JSON payloads :
Request(MY_TYPE, text="hello")/Request(MY_TYPE, json={"k": "v"}) - Content decoding :
response.text,response.json,response.is_json,response.is_text - Convenience send :
server.send()/client.send()- no need to touchSenderdirectly - Built-in ping/pong : bidirectional latency measurement
- Client tags : attach arbitrary metadata to connected clients
Reliability
- Auto-reconnect : configurable retry with
DisconnectStatecallbacks SMALL/MEDIUM/LARGEbuffer size presets- Swappable socket backends via
SocketCore(Threading or Async/Selectors)
Developer Experience
- Integrated logger : colorized, file-rotating, thread-safe
- 844 tests, CI on Python 3.11 / 3.12 / 3.13 / 3.14 (Rust engine and pure-Python fallback)
Performance¶
Rust engine vs Python fallback (v3.2.0) - Python 3.14.8, 12-core CPU, 5-run averages:
| Metric | Rust engine | Python fallback | Gain |
|---|---|---|---|
| Concurrent stress (100 clients) | 133,312 msg/s | 110,650 msg/s | +20% |
| Latency P99 | 0.086 ms | 0.116 ms | -26% |
| FPS 64 tick stdev | 0.233 ms | 0.230 ms | ±0 (noise) |
| Burst send | 65,132 msg/s | 58,082 msg/s | +12% |
Socket backends, pure-Python path (Python 3.14.8, 12-core CPU, 30.5 GB RAM, loopback):
| Metric | Threading | Async |
|---|---|---|
| Concurrent stress (100 clients) | 52,596 msg/s | 110,216 msg/s (2.1x) |
| Burst send | 65,907 msg/s | 56,675 msg/s |
| Average latency | 0.041 ms | 0.056 ms |
| Idle server memory | ≈0 (noise) | ≈0 (noise floor) |
Full details : Performance
When NOT to use Veltix¶
Veltix is great for TCP, but not every problem is a TCP problem.
- HTTP/REST APIs : use Flask, FastAPI, or Django REST Framework
- Browser clients : Veltix speaks raw TCP, not WebSocket; use
websocketsor Socket.IO - Async-first codebases : Veltix is sync by design; use
asynciodirectly if your whole project is async - Ultra high throughput (>100k msg/s per connection) : consider a compiled language for the hot path
- Single request-response : if you just need to fetch something once,
requestsorurllibis simpler
Everything else? Veltix has you covered.
Comparison¶
| Feature | Veltix | socket |
asyncio |
Twisted |
|---|---|---|---|---|
| High-level 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 | ✓ | ✗ | ~ | ✓ |
| Content decoding | ✓ | ✗ | ✗ | ✗ |
✓ Built-in ~ Possible but requires manual setup ✗ Not provided (you implement it yourself)
In Development¶
- Encryption (TLS) : native transport encryption, planned for the end of 2026, possibly earlier. Until then, Veltix runs in plaintext; see the warning at the top of this page.
- Handshake hardening : more robust handshake handling, from per-step timeouts to cleaner version negotiation and failure recovery.
- Performance optimization : the remaining hot-path overhead, now that framing/parse/compile run in Rust.
Experiment work lands on dedicated branches and only merges once fully validated.