in reply to Re: Rapid inter-machine communication on internal network
in thread Rapid inter-machine communication on internal network
use RPC::Lite::Client; our @clients; our @server_info; sub setup { foreach my $info (@server_info) { push @clients, RPC::Lite::Client->new({ Transport => "TCP:Host=$info->{host},Port=$info->{port}", # default serializer is JSON, and XML is also available }); } } sub query { my ($what) = @_; my ($responses, $result); # anon sub will be called with any responses from the server foreach my $client (@clients) { $client->AsyncRequest( sub { $responses++; $result += $_[0] }, 'getCount', $what ); } # The API should support aggregating multiple clients so you can # replace the inner foreach with one call, but it doesn't yet. while ($responses < @clients) { foreach my $client (@clients) { $client->HandleResponse; # pump server for data } } return $result; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Rapid inter-machine communication on internal network
by sfink (Deacon) on Nov 03, 2006 at 06:43 UTC |