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.

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.

53k msg/s0.004ms latency84KB idle100% 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
  • LOW / BALANCED / HIGH performance mode presets
  • Swappable socket backends via SocketCore (Threading now, Selectors in v1.7.0, Rust in v3.0.0)

Developer Experience

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

Performance

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

Metric Result
Concurrent stress (100 clients) 52,655 msg/s — 100% success
Burst throughput 73,964 msg/s send / 53,976 msg/s recv
Average latency 0.004ms
Idle server memory 84 KB
FPS simulation (64 players @ 64Hz) 4,490 msg/s — 100% success

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.7 : Architecture Refactor (May 2026) : Released

ClientContext Protocol, Rules system for RequestHandler, README rewrite

v1.7.0 : Selectors (June 2026) : Planned

AsyncSocket : selectors-based I/O, same API, 4-8x throughput improvement

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.6.8.tar.gz (63.1 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.6.8-py3-none-any.whl (62.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for veltix-1.6.8.tar.gz
Algorithm Hash digest
SHA256 a75fc59211593caa4e0208174f83a8ad7b205fc9ea18f7ac790fd48b502e0784
MD5 b15eb47c1bf8eb2da3e765979195b7cc
BLAKE2b-256 d72fcf7a91e66edabd2728c5fd85386d60fb685b0741bd4844d0a13d6c950131

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for veltix-1.6.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7ba907066d1894d0d7e0112ba226f147db7c0e1f947e91acedae74284c0a34e6
MD5 203300116bf588d2d755868afb715622
BLAKE2b-256 bc355de9dd3a2c4fe966de884b95be42b06faa0e10036e6d2cb864c834550894

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