Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Storable freeze/thaw losing object methods

by unix_hacker_beard (Novice)
on Nov 22, 2011 at 19:44 UTC ( #939524=perlquestion: print w/ replies, xml ) Need Help??
unix_hacker_beard has asked for the wisdom of the Perl Monks concerning the following question:

I am writing an IPC shell module to provide interprocess runtime hooks. I am using freeze and thaw from the Storable module to pass Command objects over a socket on localhost. Before freezing the object, these methods are available:

RETURN_IN_ORDER GetOptions DESTROY run AUTOLOAD ISA BEGIN PERMUTE isa new _init REQUIRE_ORDER

However, after thawing, only AUTOLOAD and DESTROY are available.

Here is the code for sending the frozen object over the socket (I've ensured send is working properly)

$self->{channel}->send(freeze(\$command));

And for unthawing (again, I know receive_nb to work properly)

my $command = thaw($self->{channel}->receive_nb());

Comment on Storable freeze/thaw losing object methods
Select or Download Code
Re: Sorable freeze/thaw losing object methods
by BrowserUk (Pope) on Nov 22, 2011 at 19:47 UTC

    Have you checked the size of what you receive is the same as the size of what you send?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I have not, but my assumption was if the serialized object was getting truncated in the process, it would no longer be unserializable (dangerous assumption since I haven't looked into how freeze/thaw work). How can I check the size of an object?
        How can I check the size of an object?

        Check the size of the transmission:

        my $toSend = freeze(\$command ); print length $toSend; $self->{channel}->send( $toSend ); ... my $received = $self->{channel}->receive_nb(); print length $received; my $command = thaw( $received );

        But ikegami's probably hit the nail on the head. Have you used the class at the receiver?


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Storable freeze/thaw losing object methods
by ikegami (Pope) on Nov 22, 2011 at 20:14 UTC
    Objects don't have methods; classes do. Did you load the module providing the class?
      Yes, I did provide the module.
      You were correct. I had neglected to require the module once more in the separate process. Thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://939524]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2014-09-22 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (202 votes), past polls