RPC/RMI in Perl

Kaoru kaoru at slackwise.net
Tue Oct 14 16:47:37 BST 2008

Hey guys,

I've been looking through CPAN for some sort of RPC/RMI (Remote
Procedure Call/Remote Method Invocation) module that will let us pass
objects and data structures from machine to machine via network
connections. We're looking for something similar to the regular
client-server module, except the client and server need to be able to
pass objects around and maintain state. So far I've tried the

* Event::RPC

So close, but unfortunately it doesn't seem to pass objects around
quite how I was hoping. Whenever an object on the server side returns
an object to the client it instead creates the new object as a new
_remote_ object, which unfortunately makes it difficult to access
internal data stored in that object. In the case I was trying the
object returned stored data like so:

sub new { bless { 'var' => '' }, shift }
sub var {
    my $self = shift;
    my $var = shift;
    if ($var) {
        $self->{'var'} = $var;
    return $self->{'var'};

Which didn't work because when you call $remote_object->var("new
value"); the scalar passed into var() is _not_ the object but the
handle to the object, ie it looked like this:

bless( do{\(my $o = 'Name::Of::Module=HASH(0xbce5a0)')}, 'Name::Of::Module' );

not this:

bless( { 'var' => '' }, 'Name::Of::Module' );

I think the "make the object on the server side and pass back a
handle" is close to what Java RMI does, but it seems broken in Perl.

* RPC::Serialized

Again pretty close. This passes objects around using the
Data::Serializer module and uses Net::Server for its network
connections, seems very customisable. Unfortunately it also has
trouble keeping state since it uses the Net::Server::PreFork
"personality"... State is kept fine as long as you keep talking to the
same process, but the second you switch to a different process all
your state is lost. I might end up using this with only one (zero?)
forked process and see how that goes.

* GRID::Machine

Calls over SSH and passes all the code from the client to the
server(s) in string form. Not really what we're looking for.


Is there anything obvious I'm missing? Is there a book out there on
RPC/RMI in Perl? Any hint and tips would be greatly appreciated :)

Thanks in advance,

- Alex

More information about the london.pm mailing list