Python socket server: listening to multiple clients [closed]

in short, you have 3 main options:

  1. open a thread per client, that spawns after you accept(), and the run a loop in this context, that does read() => .... => write()

  2. run a main loop that uses select() on clients after accept() for each, and handle dispatching yourself.

  3. best option – use an async networking framework like tornado, gevent, twisted or a few more to handle this transparently.

Leave a Comment