Linux Networking Programming

Trio Tutorial – Simple TCP Chat Program – Part 1

I’ve made a video about making a simple TCP-based program using Python and Trio. The video is here:

The features I plan to build are:

  • each user has a long running tcp connection
  • user is asked for name on connection
  • user sends message
  • each other connected user receives the message

In part 1 we get the basic connectivity working, and build the ability for a user to send through a username on connection.

To listen for connections we use the trio.serve_tcp function:

When a user connects it calls our async function, and provides it a trio.SocketStream :

Got any questions? Contact me:

Leave a Reply

Your email address will not be published. Required fields are marked *