For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > June 2004 > Help with threading and returning results









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help with threading and returning results
Sean

2004-06-28, 8:58 pm

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
Ben Morrow

2004-06-28, 8:58 pm


Quoth aether8203@yahoo.com (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.me.uk
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com