TCP networking in Python is painful. You deal with raw sockets, manual buffering, thread management, message framing... it's a lot just to send a message between two programs.
So I built Veltix — an open-source Python library that makes real-time TCP networking simple and intuitive.
What does it look like?
Server:
from veltix import Server, ServerConfig, Events, MessageType
MSG = MessageType(code=300, name="chat")
server = Server(ServerConfig(host="0.0.0.0", port=8080))
def on_message(client, response):
print(f"Received: {response.content.decode()}")
server.set_callback(Events.ON_RECV, on_message)
server.start()
Client:
from veltix import Client, ClientConfig, Request, MessageType
MSG = MessageType(code=300, name="chat")
client = Client(ClientConfig(server_addr="127.0.0.1", port=8080))
client.connect()
client.get_sender().send(Request(MSG, b"Hello Server!"))
That's it. No raw sockets, no manual buffering, no thread management.
What does Veltix handle for you?
- TCP stream fragmentation — messages are always received complete, even if split across multiple packets
- Message integrity — every message is SHA-256 hashed and verified automatically
- PING/PONG — built-in latency measurement
- send_and_wait() — send a request and block until you get the matching response, like an HTTP request
- Broadcasting — send to all connected clients in one call
-
Thread-safe callbacks — your
on_recvruns in a thread pool, so slow callbacks never block message reception
Why I built it
I wanted to build real-time applications in Python without writing the same boilerplate networking code every time. Libraries like asyncio are powerful but have a steep learning curve. I wanted something that felt as simple as FastAPI but for persistent TCP connections.
Performance
Benchmarked on Python 3.14, Linux:
- Average latency: 0.012ms
- Throughput: 67,000+ msg/s burst
- 64 players @ 64 tick/s: 100% message delivery
Current status
Veltix is at v1.3.0 with 2000+ downloads in 2 months. It's stable, tested, and ready to use.
What's next?
- v1.4.0 — HELLO/HELLO_ACK handshake + thread pool for callbacks (coming soon)
-
v1.5.0 — decorator-based message routing (
@server.route(MY_TYPE)) - v1.6.0 — plugin system
Links
- 📦 PyPI: https://pypi.org/project/veltix
- 💻 GitHub: https://github.com/NytroxDev/Veltix
I'd love to hear what you think — feedback, questions, or ideas are very welcome!
Top comments (0)