ThreadingTCPServer, asyncore and Client-to-Client communication
Bryan Olson
fakeaddress at nowhere.org
Mon Aug 9 03:03:08 EDT 2004
Dustin wrote:
[...]
> If Client #1 connects, then that thread is consumed with listening for
> data from that client. If Client #2 connects, that client is on a
> different thread, and therefore I don't see how I can have data sent
> from Client #1 to be streamed down to Client #2.
[...]
> I've looked at asyncore/asynchat, as well as ThreadingTCPServer... but
> there's something I'm missing. Is there a simple way to have an
> object listen over two ports, and what comes into one port will be
> sent down the another?
Yes; look up the select module in the standard library (on which
asyncore is built).
Also, note that sockets are not bound to a single thread. If
you don't want to use select, you might have one thread that
reads from socket x and writes to socket y, and another thread
that reads from y and write to x. Some perfectly reasonable
systems have a reading thread and a writing thread for each
socket.
--
--Bryan
More information about the Python-list
mailing list