ThreadingTCPServer, asyncore and Client-to-Client communication

Discussion in 'Python' started by Dustin, Aug 8, 2004.

  1. Dustin

    Dustin Guest

    I've been trying to create a "byte streaming server", it's basically a
    chat server, but I'd like to use it for transfering large amounts of
    data between two connected clients. Sounds simple enough, but I'm
    having a difficult time implementing it.

    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. (and how can client
    process #1 accept data from client #2 because it's listening to client
    #1?) Obviously I'm missing something.

    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?

    Any advice, or a good swift kick in the right direction would be
    appreciated.
    Dustin
     
    Dustin, Aug 8, 2004
    #1
    1. Advertising

  2. Dustin

    Bryan Olson Guest

    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
     
    Bryan Olson, Aug 9, 2004
    #2
    1. Advertising

  3. Dustin

    G. S. Hayes Guest

    (Dustin) wrote in message news:<>...
    > I've been trying to create a "byte streaming server", it's basically a
    > chat server, but I'd like to use it for transfering large amounts of
    > data between two connected clients. Sounds simple enough, but I'm
    > having a difficult time implementing it.


    investigate os.select; you don't even need multiple threads for this operation.
     
    G. S. Hayes, Aug 9, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. UrgeOverkill
    Replies:
    2
    Views:
    447
    Peter Hansen
    Feb 19, 2004
  2. Stuart D. Gathman

    Debugging SocketServer.ThreadingTCPServer

    Stuart D. Gathman, Jan 16, 2007, in forum: Python
    Replies:
    0
    Views:
    334
    Stuart D. Gathman
    Jan 16, 2007
  3. Jean-Paul Calderone

    Re: Debugging SocketServer.ThreadingTCPServer

    Jean-Paul Calderone, Jan 16, 2007, in forum: Python
    Replies:
    2
    Views:
    392
    R. Bernstein
    Feb 4, 2007
  4. Brad Brock
    Replies:
    0
    Views:
    342
    Brad Brock
    May 19, 2007
  5. Daniel
    Replies:
    1
    Views:
    372
    Vinay Sajip
    Oct 18, 2008
Loading...

Share This Page