NAME

IO::Event::Callback - A closure based API for IO::Event

SYNOPSIS

IO::Event::Callback->new($filehanle, %callbacks);
IO::Event::INET::Callback->new(%socket_info, %callbacks);
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.

EXAMPLE

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 exmaple use of IO::Event::Callback.