Python socket server: listening to multiple clients -
i must listen incoming connections @ same time have receive messages connected clients. listen(1) makes socket waiting can't receive them. do? (i have messages client sends them)
in short, have 3 main options:
open thread per client, spawns after
accept(), , run loop in context,read() => .... => write()run main loop uses
select()on clients afteraccept()each, , handle dispatching yourself.best option - use async networking framework
tornado,gevent,twistedor few more handle transparently.
Comments
Post a Comment