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.

52k msg/s0.006ms latency212KB 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
  • SMALL / MEDIUM / LARGE buffer size 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.5 — 12-core CPU, 30.5 GB RAM, Linux (loopback).

Metric Result
Concurrent stress (100 clients) 38,985 msg/s — 100% success
Burst throughput 52,377 msg/s send / 41,496 msg/s recv
Average latency 0.006 ms
Idle server memory 212 KB
FPS simulation (64 players @ 64Hz) 4,488 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.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 : 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.10.tar.gz (64.0 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.10-py3-none-any.whl (63.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for veltix-1.6.10.tar.gz
Algorithm Hash digest
SHA256 bb2a9c169ee1100762ede04512b51886c3087fcbc35ac6005fb6f0836af83643
MD5 65174e6ffab641df8257d252baf02352
BLAKE2b-256 0bdfa630faf9425950513e0bcb8b202b1328629dc1b1750dfb3487af3dcedad3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: veltix-1.6.10-py3-none-any.whl
  • Upload date:
  • Size: 63.3 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.6.10-py3-none-any.whl
Algorithm Hash digest
SHA256 54f4132fac3f54e114485008b9ce7413b6bfabe11cca78c91f0d8a6670d11066
MD5 44784efdc003e1e8aa03a754dc55d88f
BLAKE2b-256 195a3d6988c19100aaf8722a6cbf00814b9852a44292a5e047a82a8d65d2f315

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