Synchronous, thread-friendly
Plain blocking calls that fit normal threaded code. No event loop to adopt, no architecture to rewrite around.
server.start()
client.send(Request(CHAT, text="hi"))
Python 3.11+ / zero deps / v3.2.1
Veltix is a synchronous, thread-friendly TCP library. Straightforward API, optional Rust engine under the hood, and no runtime dependencies.
01 / Features
Plain blocking calls that fit normal threaded code. No event loop to adopt, no architecture to rewrite around.
server.start()
client.send(Request(CHAT, text="hi"))
Nothing to install beyond Veltix itself. Small surface, standard library only.
pip install veltix
# no extra dependency
The message hot path runs in Rust when it is available, with a pure-Python fallback. Chosen at runtime.
disable_rust() # force the pure-Python engine enable_rust() # use the compiled engine
Define a MessageType, decorate a handler, done. Framing and dispatch are handled for you.
CHAT = MessageType("chat") @server.route(CHAT) def on_message(client, response) -> None: server.broadcast(Request(CHAT, response.text))
send_and_wait() correlates replies for you, with timeouts. Plus broadcast, tags and reconnection built in.
response = client.send_and_wait(
Request(CHAT, b"data"), timeout=3.0)
response.text, response.json, response.is_json. Lazy decoding, no manual bytes juggling.
Request(CHAT, json={"key": "value"})
response.json # parsed
response.is_json # bool, never raises
02 / Code
pip install veltix
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, response.text)) server.start() server.wait_until_closed()
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()
Async backend available too: SocketCore.ASYNC for 100+
clients, SocketCore.THREADING for simple apps.
03 / Performance
| Metric | Threading | Async | Factor |
|---|---|---|---|
| Concurrent stress (100 clients) | 52,596 msg/s | 110,216 msg/s | 2.1x |
| Average latency | 0.041 ms | 0.056 ms | 1.4x |
| Memory per client | 91 KB | 57 KB | 1.6x |
| FPS simulation (64 players @ 64 Hz) | 4,490 msg/s | 4,490 msg/s | 1.0x |
04 / Start
pip install veltix / Python 3.11+ / MIT