Skip to main content

Veltix

Python TCP, without the boilerplate.

CI Lines of code PyPI Python License Downloads Security Policy AI Guide Website

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 - 761 tests (plus 83 vendored Avyra tests) · CI on Python 3.11-3.14 · Rust-powered hot path


Table of Contents


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 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.

What you get out of the box:

  • Message framing: no more recv() loops and buffer handling
  • Protocol routing: @server.route(MY_TYPE) instead of if/elif chains
  • Automatic handshake: JSON raw-socket protocol with version compatibility
  • Built-in ping/pong: bidirectional latency measurement, zero config
  • Auto-reconnect: configurable retry with disconnect state callbacks
  • Message integrity: CRC32 verification on every message
  • Request/Response: send_and_wait() with timeout and correlation
  • Convenience send: server.send() / client.send(): no need to touch Sender directly
  • Content decoding: response.text and response.json: lazy, cached
  • Text & JSON payloads: Request(MY_TYPE, text="hello") / Request(MY_TYPE, json={"x": 1})
  • Thread-safe callbacks: slow handlers never block reception
  • Client tagging: attach metadata, broadcast to groups
  • Integrated logger: colorized, rotating, thread-safe
  • Structured event bus: powered by Avyra: subscribe to lifecycle, message, protocol, and error events
  • Rust-powered engine: framing / parse / compile in native Rust - with automatic pure-Python fallback

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


Installation

pip install veltix

Requirements: Python 3.11+, no runtime dependencies. Prebuilt wheels ship the compiled Rust engine (one cp311-abi3 wheel per platform); when the native component is unavailable, Veltix automatically falls back to the pure-Python implementation. Building from source requires a Rust toolchain (handled automatically by the maturin build backend).


Quick Start

Server:

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

CHAT = MessageType("chat")

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


@server.route(CHAT)
def on_message(client: ClientInfo, response: Response) -> None:
    print(f"[{client.ip}] {response.text}")
    server.broadcast(Request(CHAT, text=response.text), except_clients=[client])


server.start()
server.wait_until_closed()

Client:

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

CHAT = MessageType("chat")

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


@client.route(CHAT)
def on_message(response: Response) -> None:
    print(f"Server: {response.text}")


client.connect()

client.send(Request(CHAT, text="Hello Server!"))
client.wait_until_closed()
python server.py
python client.py  # In a separate terminal

Key Features

# Content decoding (lazy, cached)
response.text  # UTF-8 string
response.json  # parsed JSON
response.is_json  # bool, no exception

# Text & JSON payloads (no manual encoding)
Request(MY_TYPE, text="hello")
Request(MY_TYPE, json={"key": "value"})

# Request/Response correlation
response = client.send_and_wait(Request(MY_TYPE, b"data"), timeout=3.0)

# Server convenience
server.send(request, client)
server.broadcast(request)
server.broadcast(request, except_clients=[client])
server.wait_until_closed()
server.restart()

# Client convenience
client.send(request)
client.send_and_wait(request, timeout=5.0)
client.ping_server()
client.wait_until_closed()
client.stop_retry()

# Client tags
client.add_tag("channel", "general")
targets = server.get_clients_by_tag("channel", "general")

# Rust engine switch (captured at each Server/Client initialization:
# construction, server.restart(), client reconnection)
disable_rust()  # force the pure-Python engine
enable_rust()  # re-enable the compiled Rust engine (when installed)

Rust-powered hot path

Since v3.0.0, message parsing, compilation, and buffering run on a Rust-powered hot path.

Benchmarks against the Python fallback:

  • +20% throughput under 100-client stress (133k vs 111k msg/s)
  • -26% latency P99 (0.086 ms vs 0.116 ms)
  • +12% burst send throughput (65k vs 58k msg/s)
  • Comparable FPS tick stability (both within run-to-run noise)

The engine is picked at runtime: disable_rust() forces the pure-Python fallback, enable_rust() re-enables the compiled engine (see veltix.network._rust.rust_enabled()). The choice is captured when a Server / Client is (re)initialized - construction, server.restart(), client reconnection.

Results are workload-dependent and were measured on Veltix 3.2.0 (Python 3.14.8, loopback).


Backend Comparison: Threading vs Async

Veltix lets you switch between two socket backends via SocketCore. Pick the one that fits your use case.

Criteria Threading (SocketCore.THREADING) Async (SocketCore.ASYNC)
Model One thread per client Single-threaded event loop (selectors)
Best for Simple apps, < 50 clients, predictable loads High concurrency, 100+ clients, variable loads
Concurrent stress ~53k msg/s ~110k msg/s (2.1x)
Idle memory ≈0 server (noise) + 91 KB per client ≈0 server (noise floor) + 57 KB per client
Latency 0.041 ms 0.056 ms
Debugging Straightforward (stack traces = threads) Harder (event loop internals)

Quick rule of thumb:

  • Few clients, simple logic, want easy debugging? Use THREADING.
  • Many clients, high throughput, memory-conscious? Use ASYNC.
from veltix import Server, ServerConfig, SocketCore

server = Server(ServerConfig(socket_core=SocketCore.THREADING))  # or .ASYNC

Performance

Benchmarked on Python 3.14.8: 12-core CPU, 30.5 GB RAM, Linux (loopback), 5-run averages. On v3.0.0+ the message hot path runs in Rust - see Rust-powered hot path for the Rust engine vs pure-Python fallback numbers.

Metric Threading Async
Concurrent stress (100 clients) 52,596 msg/s 110,216 msg/s (2.1x)
Burst throughput 65,907 / 55,936 56,675 / 44,146
Idle server memory ≈0 (noise) ≈0 (noise floor)
Per client memory (avg) 91 KB 57 KB (noisy)
Average latency 0.041 ms 0.056 ms
FPS simulation (64 players @ 64Hz) 4,490 msg/s 4,490 msg/s

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


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 websockets or Socket.IO
  • Async-first codebases: Veltix is sync by design; use asyncio directly 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, requests or urllib is simpler

Everything else? Veltix has you covered.


Comparison

Feature Veltix socket asyncio Twisted
Explicit API ✓ ✗ ✗ ✗
Sync API ✓ ✓ ✗ ✗
No async required ✓ ✓ ✗ ✗
Zero dependencies ✓ ✓ ✓ ✗
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

What is being worked on right now:

  • 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).
  • Handshake hardening: more robust handshake handling, from per-step timeouts to cleaner version negotiation and failure recovery.
  • Performance optimization: now that framing/parse/compile run in Rust, pushing the remaining hot-path overhead further. See PERFORMANCE.md.

Experimental work lands on dedicated branches and only merges once fully validated.


Documentation


Contributing

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


License

MIT License: see LICENSE for details.


Metadata

Release files for veltix 3.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for veltix 3.3.0
File Size Uploaded Provenance
veltix-3.3.0.tar.gz 106.9 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for veltix 3.3.0
File
veltix-3.3.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
veltix-3.3.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details
veltix-3.3.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details
veltix-3.3.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
veltix-3.3.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 2.1 MB

Release files / veltix-3.3.0.tar.gz

Download URL veltix-3.3.0.tar.gz
Size 106.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c82334d8cb47c54ec098e7bfc284242b0cf617a851d72aacf29146d9db1ca9d4
BLAKE2b-256 checksum
How to use checksums
b7ca32b6da5ef5073df8c86a6f18426d54ceaee7323c34a0487a51685756a8bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / veltix-3.3.0-cp311-abi3-win_amd64.whl

Download URL veltix-3.3.0-cp311-abi3-win_amd64.whl
Size 291.8 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0a593bbba9d53b51bcbb789f9a0d72ab00b270f322c5cc9a84923c9eb8c66892
BLAKE2b-256 checksum
How to use checksums
480dbd83a4fa2d3a9fb5c5dc60d9db0f807e92385569428df137b1b4a3a46142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / veltix-3.3.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL veltix-3.3.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 433.9 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
745dc674311b78aa18cd9ceb8df8cf59bacf6e11dd20350a72b16e078ac543c4
BLAKE2b-256 checksum
How to use checksums
ca62daff3a2bac5cbc4469783e5856cced3facfb2651323089f3bde264ac749a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / veltix-3.3.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL veltix-3.3.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 429.9 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
24fd6071d5798ecabe7279421b1ae4899559cb9a93be5d8f3fdbc72cfc260c26
BLAKE2b-256 checksum
How to use checksums
b0a32e4a02496fc590e73faa22033fd28ec78a99d86102f1d4bcb2143e4a1df6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / veltix-3.3.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL veltix-3.3.0-cp311-abi3-macosx_11_0_arm64.whl
Size 395.8 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2f40b4672b733d68ca02422e2b3fc52c7d75bf14cba8826cc1a7c3713a399e3b
BLAKE2b-256 checksum
How to use checksums
3b37e5767579d109a118d64ba44a6fc1a3a5b7fb304b8360d6603cbfba7f3911
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / veltix-3.3.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL veltix-3.3.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 396.7 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f3b1665b17d3422eaaffab09f459e4c9eac78c85cbd04c94f234c169d201cb5b
BLAKE2b-256 checksum
How to use checksums
f41c7525563893e69f05530171c17585fc9437ab44479c2e0f250358a9e1b0c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for veltix 3.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for veltix-3.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.3.0 This release

6 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page