Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  RPC::SIMPLE::ANYLOCAL (3)

.ds Aq ’


RPC::Simple::AnyLocal - Perl extension defining a virtual SRPC client class



 package MyLocal ;

 use RPC::Simple::AnyLocal;
 use vars qw($VERSION @ISA @RPC_SUB) ;
 @ISA = qw(RPC::Simple::AnyLocal [other_class] );
 @RPC_SUB = qw(remoteHello remoteAsk);

 sub new
    my $type = shift ;

    my $self = {} ;
    my $remote =  shift ;
    bless $self,$type ;

    $self->createRemote($remote,your_class_name) ;
    return $self ;

 # Note that the remoteHello method is not part of MyLocal

 package main;

 use Tk ;
 use RPC::Simple::Server ;
 use RPC::Simple::Factory ;

 my $pid = &spawn ; # spawn server if needed

 # client part
 my $mw = MainWindow-> new ;
 my $verbose = 1 ;

 # create factory
 my $factory = new RPC::Simple::Factory($mw,\$verbose) ;
 my $local = new MyLocal($factory) ;
 $mw -> Button (-text => quit, -command => sub {exit;} ) -> pack ;
 $mw -> Button (-text => remoteAct,
   -command => sub {$local->remoteHello();} ) -> pack ;

 MainLoop ; # Tks


This class must be inherited by a sub-class so this one can use the RPC facility.

Note that this class (and the Factory class) was designed to use Tk’s fileevent facilities.

The child object must declare in the @RPC_SUB array the name of the methods available on the remote side.


    createRemote(factory_object_ref, [remote_class_name], ... )

This method should be called by the child object during start-up. It will ask the SRPC factory to create a ClientAgent class dedicated to this new object.

The server on the other side of the socket will load the code necessary for the remote class. By default the remote class name will be ...::Real<LocalClass>. I.e if your local class is Test::Foo the remote class name will be Test::RealFoo.

If the remote class name has no prefix, ’.pm’ will be appended to get the file name to load

The remaining parameters will passed to the remote object’s new method during its creation.

returns self.


Objects derived from AnyLocal must be explicitely destroy. If you just undef the object reference, you will not release the memory and the remote object will not be destroyed.


When this method is called (generally through perl mechanism), the call will be forwarded with all parameter to the remote object. If the first parameters is : \&one_callback

the function &one_callback will be called when the remote side has finished its function.

If you want to call-back an object method, use a closure. Such as

 $self->remote_method(sub {$self-> finished(@_)})

Note that if the remote method name is not declared in the @RPC_SUB array, AnyLocal will try to autoload this method.

returns self.

instance variable

AnyLocal will create the following instance variables:


Will contains the ref of the RPC::Simple::Agent object.


Will contains the name of the remote host.

Inheritance and Autoload

Since RPC::Simple uses the AUTOLOAD subroutine to delegate unknown calls to the remote class, you must pay attention if you use or inherit classes which use the AutoLoader mechanism.

The AUTOLOAD defined in this class will first check if the called function is declared in the @RPC_SUB arrays of all inherited classes. If yes it will call the remote function. If not it will forward the call to the AutoLoader::AUTOLOAD routine. In this case you fall back on the usual AutoLoad mechanism.

For this scheme to work, it is important that RPC::Simple::AUTOLOAD is run BEFORE the AutoLoader::AUTOLOAD routine.

So when inheriting from RPC::Simple and another class (say Foo::Bar), you must put RPC::Simple::AnyLocal BEFORE your class in the @ISA array.

For instance, you must declare : @ISA = qw(RPC::Simple::AnyLocal Foo::Bar);

BTW, if you are mixing autoloading, remote calls and inheritance, which is a recipe for a good headache, you really (I mean it) should use subroutine stubs for the auloaded functions. (It does really work better). See AutoLoad(3).


    Current Maintainer
    Clint Edwards <>

    Dominique Dumont, <>


perl(1), RPC::Simple::Factory(3), RPC::Simple::AnyRemote(3)
Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 SIMPLE::ANYLOCAL (3) 2006-05-31

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.