in reply to Re^2: Forking Clients
in thread Forking Clients
You need to wrap the while loop in a for loop that iterates once for each client you start:
use strict; use threads; use threads::shared; ### I omitted this from my example above initiall +y. use Thread::Queue; use ClarRPC; my $queue = new Thread::Queue; rpc('10.15.51.208', '1300', 'ping -n 50 10.15.51.208'); rpc('10.15.51.208', '1301', 'ping -n 10 10.15.51.208'); rpc('10.15.51.208', '1302', 'ping -n 50 10.15.51.208'); for( 1 .. 3 ) { ## Must iterate once for each thread started ### while (my $ref = $queue->dequeue) { my ($port, @results) = @$ref; print "$port : @results\n"; } } sub rpc { my ($ip, $port, $command) = @_; async{ my $connection = ClarRPC->connect($ip, $port); my @resp :shared = $connection->rpc( 'ClarRPCService::system_call', $command ); $connection->disconnect(); unshift(@resp, $port); $queue->enqueue(\@resp, undef); }->detach }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Forking Clients
by gepapa (Acolyte) on Oct 15, 2008 at 17:55 UTC | |
by BrowserUk (Patriarch) on Oct 15, 2008 at 18:31 UTC | |
by gepapa (Acolyte) on Oct 15, 2008 at 19:05 UTC | |
by BrowserUk (Patriarch) on Oct 15, 2008 at 23:04 UTC | |
by gepapa (Acolyte) on Oct 16, 2008 at 13:11 UTC | |
| |
by mr_mischief (Monsignor) on Oct 15, 2008 at 21:05 UTC | |
by gepapa (Acolyte) on Oct 16, 2008 at 12:31 UTC | |
|