NAME
IO::Event::Callback - A closure based API for IO::Event
VERSION
version 0.814
SYNOPSIS
use IO::Event::Callback;
IO::Event::Callback->new($filehanle, %callbacks);
use IO::Event::INET::Callback;
IO::Event::INET::Callback->new(%socket_info, %callbacks);
use IO::Event::UNIX::Callback;
IO::Event::UNIX::Callback->new(%socket_info, %callbacks);
DESCRIPTION
IO::Event::Callback is a wrapper around IO::Event. It provides an alternative interface to using IO::Event.
Instead of defining a class with methods like "ie_input", you provide the callbacks as code references when you create the object.
The keys for the callbacks are the same as the callbacks for IO::Event with the ie_ prefix removed.
CONSTRUCTORS
new
my $ioe = IO::Event::Callback->new($filehandle, %callbacks);
Create an IO::Event object for $filehandle whose handler invokes the given callbacks. The keys of %callbacks are the IO::Event handler names, with or without the ie_ prefix (for example input or ie_input). The read_only and write_only options are passed through to IO::Event.
EXAMPLE
use IO::Event::Callback;
my $remote = IO::Event::Callback::INET->new(
peeraddr => '10.20.10.3',
peerport => '23',
input => sub {
# handle input
},
werror => sub {
# handdle error
},
eof => sub {
# handle end-of-file
},
);
SEE ALSO
See the source for RPC::ToWorker for an example use of IO::Event::Callback.
AUTHORS
David Muir Sharnoff <cpan@dave.sharnoff.org>
Graham Ollis <plicease@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2002-2026 by David Muir Sharnoff <muir@idiom.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.