inter threading info

T

Tertius Cronje

Hi All,

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?

I wrote a socketserver using SocketServer.ThreadingTCPServer. A client
is connected to the server and expects multiple request/responses. (Not
sure about the terminology but the client connects and then stay
connected for a while.)

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
(ifile/ofile) and then send and receive specific data to those clients.

TIA
T
 
D

Daniel Dittmar

Tertius said:
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.
(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.

It sounds a bit as if you want to build some kind of chat server and now
you want to add private channels.

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,222
Messages
2,571,142
Members
47,775
Latest member
MadgeMatti

Latest Threads

Top