I'm using the XMLRPC Frontier::Daemon module which uses IO::Socket as one of it's base classes. My problem is that when I create a method for the Daemon, the sub does not appear to have an object reference (commonly set to $self or $this) as the first parameter passed. I do pass 2 paramters and they are the only ones being received by the sub. Don't ALL object methods have the object reference passed as the first parameter?

I need to acquire the $self so that I can access one of the base class methods ( connected() which is in IO::Socket ).

Strictly speaking Frontier::Daemon is a subclass of HTTP::Daemon, which is a subclass of IO::Socket::INET which is built upon IO::Socket. Sample code:

use Frontier::Daemon my $id = Frontier::Daemon->new( methods => { sum => \&sum, }, LocalAddr => '127.0.0.1', LocalPort => 80, Reuse => 1, ) or die ("Cannot start RCP daemon: $!"); sub sum { my $self = shift; # This is getting arg1 not the object reference! my $arg1 = shift; # This is getting arg2. my $arg2 = shift; ... }

Everything I read about object methods indicates that all methods should always receive the object reference as the first parameter. (Which is even discarded in most cases because it is not really needed.) But the CPAN documentation for the Frontier::Daemon (with accompanying examples) neglect to extract the reference in the object methods. Why is this server class object different from all others?

The server itself is working fine and does everything it is supposed to. I just need to give it some extra functionality and for that I need access to some class methods.

Not that it should make a difference, but the call to the Daemon constructor does not return (as it was designed this way by the module designer.)

thanks..


In reply to Missing object reference in sub by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.