Back to articles
I built a Python library to make TCP networking as simple as Fastapi

I built a Python library to make TCP networking as simple as Fastapi

via Dev.to PythonNytrox

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 manua

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
3 views

Related Articles