inter threading info

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tertius Cronje

    #1

    inter threading info

    Hi All,

    Q: Is it possible for a thread on SocketServer.Th readingTCPServe r 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.Th readingTCPServe r. 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
  • Daniel Dittmar

    #2
    Re: inter threading info

    Tertius Cronje wrote:
    [color=blue]
    > Q: Is it possible for a thread on SocketServer.Th readingTCPServe r to get
    > the socket info of *other* open thread/s and use that info to send data
    > to the accepting client?[/color]

    A specific socket can be used from every thread of a process. Just make
    sure that you synchronize everything.
    [color=blue]
    > 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[/color]

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

    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

    Comment

    Working...