Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

RPC::Async::Client
client side of asynchronous RPC framework

RPC::Async::Client - client side of asynchronous RPC framework


NAME

RPC::Async::Client - client side of asynchronous RPC framework


SYNOPSIS


  use RPC::Async::Client;

  use IO::EventMux;

  

  my $mux = IO::EventMux->new;

  my $rpc = RPC::Async::Client->new($mux, "perl://add-server.pl");

  # or # my $rpc = RPC::Async::Client->new($mux, "tcp://127.0.0.1:1234");

  $rpc->add_numbers(n1 => 2, n2 => 3,

      sub {

          my %reply = @_;

          print "2 + 3 = $reply{sum}\n";

      });

  

  while ($rpc->has_requests || $rpc->has_coderefs) {

      my $event = $rpc->io($mux->mux) or next;

  }

  $rpc->disconnect;

  

=head1 DESCRIPTION

This module provides the magic that hides the details of doing asynchronous RPC on the client side. It does not dictate how to implement initialisation or main loop, although it requires the application to use the IO::EventMux manpage.

The procedures made available by the remote server can be called directly on the the RPC::Async::Client manpage instance or via the call() method where they are further documented.


METHODS

new($mux, $url, @urlargs)
Connects to an RPC server via the URL given in $url. Such URLs can be of the forms specified in the RPC::Async::URL manpage, although it must connect to a bi-directional stream socket. Alternatively, pass an open file descriptor.

call($procedure, @args, $subref)
Performs a remote procedure call. Rather than using this directly, this package enables some AUTOLOAD magic that allows calls to remote procedures directly on the the RPC::Async::Client manpage instance.

Arguments are passed in key/value style by convention, although any arguments may be given. The last argument a remote procedure call is a subroutine reference to be executed upon completion of the call. This framework makes no guarantees as to when, if ever, this sub will be called. Specifically, remote procedures may return in a different order than they were called in.

Fairly complex data structures may be given as arguments, except for circular ones. In particular, subroutine references are allowed.

disconnect
Call this to gracefully disconnect from the server without leaving zombie processes or such.

has_requests
Returns true iff there is at least one request pending. Usually, this means that we should not terminate yet.

has_coderefs
Returns true if the remote side holds a reference to a subroutine given to it in an earlier call. Depending on the application, this may be taken as a hint that we should not terminate yet. This information is obtained via interaction with Perl's garbage collector on the server side.

io($event)
Inspect an event from EventMux. All such events must be passed through here in order to handle asynchronous replies. If the event was handled, undef is returned. Otherwise, the event is returned for processing by other RPC::Async::Client handlers or the main program itself.

dump_requests
Returns a string documenting what requests are pending. For debugging only.


AUTHOR

Troels Liebe Bentsen <tlb@rapanden.dk>, Jonas Jensen <jbj@knef.dk>


COPYRIGHT

Copyright(C) 2005-2007 Troels Liebe Bentsen Copyright(C) 2005-2007 Jonas Jensen

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy