LogicalChaos has asked for the wisdom of the Perl Monks concerning the following question:

Salutations fellow monks,

As the title implies, I would like to have a go at replicating objects across a socket. The server daemon should not be required to know anything about the object being sent, except that it implements certain methods.

After nosing around CPAN and here, my first thought is to use Data::Dumper, and just print the output across the socket. The server would then parse the data received to grab the package name, require it, and then eval the data received to reconstruct the object.

I'm hoping for conformation that this is a reasonable way to accomplish what I desire, or "This module does exactly what you want", or use these modules in this way, or...

Thanks,
LogicalChaos

Replies are listed 'Best First'.
Re: Replicating objects across a socket
by Fletch (Bishop) on Apr 03, 2002 at 19:46 UTC

    Look at SOAP::Lite or one of the CORBA modules, which will let you do this in a language agnostic manner.

Re: Replicating objects across a socket
by perrin (Chancellor) on Apr 03, 2002 at 19:54 UTC
Re: Replicating objects across a socket
by rjray (Chaplain) on Apr 04, 2002 at 01:09 UTC

    This is a very slippery slope, one whose borders delinate between remotely-separated objects being mirrors of each other and those where one side only has a handle on to the "real" object on the other end of the connection.

    CORBA and SOAP are likely the most mature, well-supported cross-platform/cross-language architectures currently in use and development. Java's RMI standard is a good example of a language-specific solution to the problem. As far as I know, there isn't currently anything RMI-like for Perl, though emerging technologies such as POE may prove to be foundations upon which people choose to start developing such things.

    --rjray

Re: Replicating objects across a socket
by kappa (Chaplain) on Apr 04, 2002 at 14:08 UTC
    And yes, taking into consideration what rjray said, you'll get what you want if you just serialize your object via Data::Dumper (or Storable network-safe n* subs, or FreezeThaw, or even XML::Dumper, or just Data::Serializer), transfer it via a socket and deserialize on the other side (requiring needed packages, of course).
    Hm, I got interested and found one more serializer (Data::Denter) I never used before :)) It's from Brian Ingerson of the mighty Inline.pm fame, so it's definitely worth a try.