inter threading info

Tertius Cronje Tertius.Cronje at postoffice.co.za
Thu Mar 24 01:58:06 EST 2005


> -----Original Message-----
> From: python-list-bounces+tertius.cronje=postoffice.co.za at python.org
>
[mailto:python-list-bounces+tertius.cronje=postoffice.co.za at python.org]
On
> Behalf Of Daniel Dittmar
> Sent: Wednesday, March 23, 2005 4:46 PM
> To: python-list at python.org
> Subject: Re: inter threading info
> 
> Tertius Cronje wrote:
> 
> > Q: Is it possible for a thread on SocketServer.ThreadingTCPServer to
get
> > the socket info of *other* open thread/s and use that info to send
data
> > to the accepting client?
> 
> A specific socket can be used from every thread of a process. Just
make
> sure that you synchronize everything.
> 
> > I need to create a client that can connect to server and then
determine
> > how many other clients are connected, what the socket info is
> 
> When you accept a socket client, a new socket is created, so you
cannot
> determine how many clients are connected to a socket. You have to
create
> a data structure where you insert info about accepted connections and
> delete the info when a connection is closed.

I was thinking of a dict or list _global_ to the
StreamRequestHandler.handle() method. That way I can pass the info on
with every new connection where the server will have access to it.

> 
> > (ifile/ofile) and then send and receive specific data to those
clients.
> 
> ifile/ofile are local to the server process so you cannot use them to
> send data from one client to another client. You have to send the data
> to the server first with a special tag, the server has to use that tag
> and send the data to the designated other client.

That's what I had in mind thanks. The server needs to keep track of all
the connected clients. 

> 
> It sounds a bit as if you want to build some kind of chat server and
now
> you want to add private channels.
>
Sounds like it but isn't. I'm busy developing a test/mock harness for a
financial switch. Currently it caters only for messages from the client
to the harness and then back. I need to add functionality that when an
_external_ message arrives, the switch can determine which client it
needs to send the data to.

Many thanks
Tertius



More information about the Python-list mailing list