Help with threading and returning results

Discussion in 'Perl Misc' started by Sean, Jun 28, 2004.

  1. Sean

    Sean Guest

    Here is the scenario:

    Unix system, 100 machines in the "pool": one server, 99 clients. Main
    program resides on the "server". On each of the 99 clients, there is
    a daemon listening on a TCP port. In the main program (on the
    server), it sends a signal out to the clients and waits for their
    responses. The clients might take mili-seconds, MANY seconds, or
    worst-case scenario lock up forever.

    What is the best approach for the main program to wait a total of X
    seconds for each of the clients responses (storing the string based
    response in a hash array??) and then continuing on with the program so
    as not to wait "forever" for the clients to respond?

    If I "fork" them (or whatever it is I do), how do I make sure to get
    their result?

    Thanks for your help and any pointers,
    Sean
     
    Sean, Jun 28, 2004
    #1
    1. Advertising

  2. Sean

    Ben Morrow Guest

    Quoth (Sean):
    > Here is the scenario:
    >
    > Unix system, 100 machines in the "pool": one server, 99 clients. Main
    > program resides on the "server". On each of the 99 clients, there is
    > a daemon listening on a TCP port. In the main program (on the
    > server), it sends a signal out to the clients and waits for their
    > responses. The clients might take mili-seconds, MANY seconds, or
    > worst-case scenario lock up forever.
    >
    > What is the best approach for the main program to wait a total of X
    > seconds for each of the clients responses (storing the string based
    > response in a hash array??) and then continuing on with the program so
    > as not to wait "forever" for the clients to respond?


    Use select (or rather IO::Select) with a timeout. No need to
    multi-{process,thread} at all.

    Ben

    --
    The cosmos, at best, is like a rubbish heap scattered at random.
    - Heraclitus
     
    Ben Morrow, Jun 28, 2004
    #2
    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. Monique Y. Mudama
    Replies:
    1
    Views:
    463
    Monique Y. Mudama
    Jun 28, 2005
  2. Christopher J. Bottaro

    Returning from socket.accept and threading issues.

    Christopher J. Bottaro, Oct 19, 2004, in forum: Python
    Replies:
    3
    Views:
    409
    Elbert Lev
    Oct 20, 2004
  3. Replies:
    9
    Views:
    1,078
    Mark Space
    Dec 29, 2007
  4. Steven Woody
    Replies:
    0
    Views:
    443
    Steven Woody
    Jan 9, 2009
  5. Steven Woody
    Replies:
    0
    Views:
    464
    Steven Woody
    Jan 9, 2009
Loading...

Share This Page