Re: Event module

[email protected] (Joshua N Pritikin)
Newsgroups perl.loop
Message-ID <[email protected]>
On Thu, Jun 08, 2000 at 05:27:35PM +1000, [email protected] wrote:
> I'm using the latest version of the Event module.
> I have a question concerning passing arguements to
> callback functions. I could not find this information
> in the pod doc.
> 
> This is what im doing.
> 
>         my $socket = IO::Socket::INET->new(
>                 Listen => 1024,
>                 Reuse => 1,
>                 Type => SOCK_STREAM,
>                 Proto => 'tcp',
>                 LocalAddr => '127.0.0.1',
>                 LocalPort => 90
>         ) or die "$!";
>         $socket->blocking(0);
> 
>         Event->io(
>                 fd => $socket,
>                 poll => 'r',
>                 repeat => 1,
>                 reentrant => 0,
>                 max_cb_tm => 2,
>                 private => $socket,
>                 cb => \&handle_client
>         );
>
> sub handle_client {
>         my $event = shift;
>         $event->w->private->accept();
> }
> 
> I want to be able to pass $socket to handle_client().
> I though i would use private to do this.

Try using the data() attribute instead of private().

> But when i try to access private using
> $event->w->private I get undef.
>
> Im wondering if you can see what im going wrong
> or if there is a better way.

Yes, well, private() saves data in a hash key'd by the caller's package.

-- 
"May the best description of competition prevail."
          via, but not speaking for Deutsche Bank
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.