1IO::Event::Callback(3)User Contributed Perl DocumentationIO::Event::Callback(3)
2
3
4

NAME

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

SYNOPSIS

9        use IO::Event::Callback;
10
11        IO::Event::Callback->new($filehanle, %callbacks);
12
13        use IO::Event::INET::Callback;
14
15        IO::Event::INET::Callback->new(%socket_info, %callbacks);
16
17        use IO::Event::UNIX::Callback;
18
19        IO::Event::UNIX::Callback->new(%socket_info, %callbacks);
20

DESCRIPTION

22       IO::Event::Callback is a wrapper around IO::Event.  It provides an
23       alternative interface to using IO::Event.
24
25       Instead of defining a class with methods like "ie_input", you provide
26       the callbacks as code references when you create the object.
27
28       The keys for the callbacks are the same as the callbacks for IO::Event
29       with the "ie_" prefix removed.
30

EXAMPLE

32        use IO::Event::Callback;
33
34        my $remote = IO::Event::Callback::INET->new(
35               peeraddr        => '10.20.10.3',
36               peerport        => '23',
37               input           => sub {
38                       # handle input
39               },
40               werror          => sub {
41                       # handdle error
42               },
43               eof             => sub {
44                       # handle end-of-file
45               },
46        );
47

SEE ALSO

49       See the source for RPC::ToWorker for an exmaple use of
50       IO::Event::Callback.
51
52
53
54perl v5.38.0                      2023-07-20            IO::Event::Callback(3)
Impressum