Help with threading and returning results

S

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?

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
 
B

Ben Morrow

Quoth (e-mail address removed) (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
 

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
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top