This might be much easier if you use gevent for the network layer: http://www.gevent.org/servers.html