1 | =head1 NAME |
1 | =head1 => NAME |
2 | |
2 | |
3 | AnyEvent - provide framework for multiple event loops |
3 | AnyEvent - provide framework for multiple event loops |
4 | |
4 | |
5 | EV, Event, Glib, Tk, Perl, Event::Lib, Qt, POE - various supported event loops |
5 | EV, Event, Glib, Tk, Perl, Event::Lib, Qt, POE - various supported event loops |
6 | |
6 | |
… | |
… | |
631 | |
631 | |
632 | =item L<AnyEvent::Handle> |
632 | =item L<AnyEvent::Handle> |
633 | |
633 | |
634 | Provide read and write buffers and manages watchers for reads and writes. |
634 | Provide read and write buffers and manages watchers for reads and writes. |
635 | |
635 | |
|
|
636 | =item L<AnyEvent::Socket> |
|
|
637 | |
|
|
638 | Provides various utility functions for (internet protocol) sockets, |
|
|
639 | addresses and name resolution. Also functions to create non-blocking tcp |
|
|
640 | connections or tcp servers, with IPv6 and SRV record support and more. |
|
|
641 | |
636 | =item L<AnyEvent::HTTPD> |
642 | =item L<AnyEvent::HTTPD> |
637 | |
643 | |
638 | Provides a simple web application server framework. |
644 | Provides a simple web application server framework. |
639 | |
645 | |
640 | =item L<AnyEvent::DNS> |
646 | =item L<AnyEvent::DNS> |
641 | |
647 | |
642 | Provides asynchronous DNS resolver capabilities, beyond what |
648 | Provides rich asynchronous DNS resolver capabilities. |
643 | L<AnyEvent::Util> offers. |
|
|
644 | |
649 | |
645 | =item L<AnyEvent::FastPing> |
650 | =item L<AnyEvent::FastPing> |
646 | |
651 | |
647 | The fastest ping in the west. |
652 | The fastest ping in the west. |
648 | |
653 | |
… | |
… | |
691 | no warnings; |
696 | no warnings; |
692 | use strict; |
697 | use strict; |
693 | |
698 | |
694 | use Carp; |
699 | use Carp; |
695 | |
700 | |
696 | our $VERSION = '3.5'; |
701 | our $VERSION = '3.6'; |
697 | our $MODEL; |
702 | our $MODEL; |
698 | |
703 | |
699 | our $AUTOLOAD; |
704 | our $AUTOLOAD; |
700 | our @ISA; |
705 | our @ISA; |
701 | |
706 | |
702 | our $verbose = $ENV{PERL_ANYEVENT_VERBOSE}*1; |
707 | our $verbose = $ENV{PERL_ANYEVENT_VERBOSE}*1; |
703 | |
708 | |
704 | our @REGISTRY; |
709 | our @REGISTRY; |
|
|
710 | |
|
|
711 | our %PROTOCOL; # (ipv4|ipv6) => (1|2) |
|
|
712 | |
|
|
713 | { |
|
|
714 | my $idx; |
|
|
715 | $PROTOCOL{$_} = ++$idx |
|
|
716 | for split /\s*,\s*/, $ENV{PERL_ANYEVENT_PROTOCOLS} || "ipv4,ipv6"; |
|
|
717 | } |
705 | |
718 | |
706 | my @models = ( |
719 | my @models = ( |
707 | [EV:: => AnyEvent::Impl::EV::], |
720 | [EV:: => AnyEvent::Impl::EV::], |
708 | [Event:: => AnyEvent::Impl::Event::], |
721 | [Event:: => AnyEvent::Impl::Event::], |
709 | [Tk:: => AnyEvent::Impl::Tk::], |
722 | [Tk:: => AnyEvent::Impl::Tk::], |
… | |
… | |
811 | package AnyEvent::Base; |
824 | package AnyEvent::Base; |
812 | |
825 | |
813 | # default implementation for ->condvar |
826 | # default implementation for ->condvar |
814 | |
827 | |
815 | sub condvar { |
828 | sub condvar { |
816 | bless {}, AnyEvent::CondVar:: |
829 | bless { @_ == 3 ? (_ae_cb => $_[2]) : () }, AnyEvent::CondVar:: |
817 | } |
830 | } |
818 | |
831 | |
819 | # default implementation for ->signal |
832 | # default implementation for ->signal |
820 | |
833 | |
821 | our %SIG_CB; |
834 | our %SIG_CB; |
… | |
… | |
944 | $_[0]{_ae_end_cb} = $_[1] if @_ > 1; |
957 | $_[0]{_ae_end_cb} = $_[1] if @_ > 1; |
945 | } |
958 | } |
946 | |
959 | |
947 | sub end { |
960 | sub end { |
948 | return if --$_[0]{_ae_counter}; |
961 | return if --$_[0]{_ae_counter}; |
949 | &{ $_[0]{_ae_end_cb} } if $_[0]{_ae_end_cb}; |
962 | &{ $_[0]{_ae_end_cb} || sub { $_[0]->send } }; |
950 | } |
963 | } |
951 | |
964 | |
952 | # undocumented/compatibility with pre-3.4 |
965 | # undocumented/compatibility with pre-3.4 |
953 | *broadcast = \&send; |
966 | *broadcast = \&send; |
954 | *wait = \&_wait; |
967 | *wait = \&_wait; |
… | |
… | |
1028 | |
1041 | |
1029 | For example, to force the pure perl model (L<AnyEvent::Impl::Perl>) you |
1042 | For example, to force the pure perl model (L<AnyEvent::Impl::Perl>) you |
1030 | could start your program like this: |
1043 | could start your program like this: |
1031 | |
1044 | |
1032 | PERL_ANYEVENT_MODEL=Perl perl ... |
1045 | PERL_ANYEVENT_MODEL=Perl perl ... |
|
|
1046 | |
|
|
1047 | =item C<PERL_ANYEVENT_PROTOCOLS> |
|
|
1048 | |
|
|
1049 | Used by both L<AnyEvent::DNS> and L<AnyEvent::Socket> to determine preferences |
|
|
1050 | for IPv4 or IPv6. The default is unspecified (and might change, or be the result |
|
|
1051 | of autoprobing). |
|
|
1052 | |
|
|
1053 | Must be set to a comma-separated list of protocols or address families, |
|
|
1054 | current supported: C<ipv4> and C<ipv6>. Only protocols mentioned will be |
|
|
1055 | used, and preference will be given to protocols mentioned earlier in the |
|
|
1056 | list. |
|
|
1057 | |
|
|
1058 | This variable can effectively be used for denial-of-service attacks |
|
|
1059 | against local programs (e.g. when setuid), although the impact is likely |
|
|
1060 | small, as the program has to handle connection errors already- |
|
|
1061 | |
|
|
1062 | Examples: C<PERL_ANYEVENT_PROTOCOLS=ipv4,ipv6> - prefer IPv4 over IPv6, |
|
|
1063 | but support both and try to use both. C<PERL_ANYEVENT_PROTOCOLS=ipv4> |
|
|
1064 | - only support IPv4, never try to resolve or contact IPv6 |
|
|
1065 | addressses. C<PERL_ANYEVENT_PROTOCOLS=ipv6,ipv4> support either IPv4 or |
|
|
1066 | IPv6, but prefer IPv6 over IPv4. |
|
|
1067 | |
|
|
1068 | =item C<PERL_ANYEVENT_EDNS0> |
|
|
1069 | |
|
|
1070 | Used by L<AnyEvent::DNS> to decide wether to use the EDNS0 extension |
|
|
1071 | for DNS. This extension is generally useful to reduce DNS traffic, but |
|
|
1072 | some (broken) firewalls drop such DNS packets, which is why it is off by |
|
|
1073 | default. |
|
|
1074 | |
|
|
1075 | Setting this variable to C<1> will cause L<AnyEvent::DNS> to announce |
|
|
1076 | EDNS0 in its DNS requests. |
1033 | |
1077 | |
1034 | =back |
1078 | =back |
1035 | |
1079 | |
1036 | =head1 EXAMPLE PROGRAM |
1080 | =head1 EXAMPLE PROGRAM |
1037 | |
1081 | |
… | |
… | |
1487 | probably even less useful to an attacker than PERL_ANYEVENT_MODEL). |
1531 | probably even less useful to an attacker than PERL_ANYEVENT_MODEL). |
1488 | |
1532 | |
1489 | |
1533 | |
1490 | =head1 SEE ALSO |
1534 | =head1 SEE ALSO |
1491 | |
1535 | |
|
|
1536 | Utility functions: L<AnyEvent::Util>. |
|
|
1537 | |
1492 | Event modules: L<EV>, L<EV::Glib>, L<Glib::EV>, L<Event>, L<Glib::Event>, |
1538 | Event modules: L<EV>, L<EV::Glib>, L<Glib::EV>, L<Event>, L<Glib::Event>, |
1493 | L<Glib>, L<Tk>, L<Event::Lib>, L<Qt>, L<POE>. |
1539 | L<Glib>, L<Tk>, L<Event::Lib>, L<Qt>, L<POE>. |
1494 | |
1540 | |
1495 | Implementations: L<AnyEvent::Impl::EV>, L<AnyEvent::Impl::Event>, |
1541 | Implementations: L<AnyEvent::Impl::EV>, L<AnyEvent::Impl::Event>, |
1496 | L<AnyEvent::Impl::Glib>, L<AnyEvent::Impl::Tk>, L<AnyEvent::Impl::Perl>, |
1542 | L<AnyEvent::Impl::Glib>, L<AnyEvent::Impl::Tk>, L<AnyEvent::Impl::Perl>, |
1497 | L<AnyEvent::Impl::EventLib>, L<AnyEvent::Impl::Qt>, |
1543 | L<AnyEvent::Impl::EventLib>, L<AnyEvent::Impl::Qt>, |
1498 | L<AnyEvent::Impl::POE>. |
1544 | L<AnyEvent::Impl::POE>. |
1499 | |
1545 | |
|
|
1546 | Non-blocking file handles, sockets, TCP clients and |
|
|
1547 | servers: L<AnyEvent::Handle>, L<AnyEvent::Socket>. |
|
|
1548 | |
|
|
1549 | Asynchronous DNS: L<AnyEvent::DNS>. |
|
|
1550 | |
1500 | Coroutine support: L<Coro>, L<Coro::AnyEvent>, L<Coro::EV>, L<Coro::Event>, |
1551 | Coroutine support: L<Coro>, L<Coro::AnyEvent>, L<Coro::EV>, L<Coro::Event>, |
1501 | |
1552 | |
1502 | Nontrivial usage examples: L<Net::FCP>, L<Net::XMPP2>. |
1553 | Nontrivial usage examples: L<Net::FCP>, L<Net::XMPP2>, L<AnyEvent::DNS>. |
1503 | |
1554 | |
1504 | |
1555 | |
1505 | =head1 AUTHOR |
1556 | =head1 AUTHOR |
1506 | |
1557 | |
1507 | Marc Lehmann <schmorp@schmorp.de> |
1558 | Marc Lehmann <schmorp@schmorp.de> |