ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent.pm (file contents):
Revision 1.226 by root, Mon Jul 6 23:32:49 2009 UTC vs.
Revision 1.230 by root, Wed Jul 8 05:55:17 2009 UTC

176=head2 I/O WATCHERS 176=head2 I/O WATCHERS
177 177
178You can create an I/O watcher by calling the C<< AnyEvent->io >> method 178You can create an I/O watcher by calling the C<< AnyEvent->io >> method
179with the following mandatory key-value pairs as arguments: 179with the following mandatory key-value pairs as arguments:
180 180
181C<fh> is the Perl I<file handle> (I<not> file descriptor) to watch 181C<fh> is the Perl I<file handle> (or a naked file descriptor) to watch
182for events (AnyEvent might or might not keep a reference to this file 182for events (AnyEvent might or might not keep a reference to this file
183handle). Note that only file handles pointing to things for which 183handle). Note that only file handles pointing to things for which
184non-blocking operation makes sense are allowed. This includes sockets, 184non-blocking operation makes sense are allowed. This includes sockets,
185most character devices, pipes, fifos and so on, but not for example files 185most character devices, pipes, fifos and so on, but not for example files
186or block devices. 186or block devices.
868 868
869 869
870=head1 OTHER MODULES 870=head1 OTHER MODULES
871 871
872The following is a non-exhaustive list of additional modules that use 872The following is a non-exhaustive list of additional modules that use
873AnyEvent and can therefore be mixed easily with other AnyEvent modules 873AnyEvent as a client and can therefore be mixed easily with other AnyEvent
874in the same program. Some of the modules come with AnyEvent, some are 874modules and other event loops in the same program. Some of the modules
875available via CPAN. 875come with AnyEvent, most are available via CPAN.
876 876
877=over 4 877=over 4
878 878
879=item L<AnyEvent::Util> 879=item L<AnyEvent::Util>
880 880
889 889
890=item L<AnyEvent::Handle> 890=item L<AnyEvent::Handle>
891 891
892Provide read and write buffers, manages watchers for reads and writes, 892Provide read and write buffers, manages watchers for reads and writes,
893supports raw and formatted I/O, I/O queued and fully transparent and 893supports raw and formatted I/O, I/O queued and fully transparent and
894non-blocking SSL/TLS. 894non-blocking SSL/TLS (via L<AnyEvent::TLS>.
895 895
896=item L<AnyEvent::DNS> 896=item L<AnyEvent::DNS>
897 897
898Provides rich asynchronous DNS resolver capabilities. 898Provides rich asynchronous DNS resolver capabilities.
899 899
927 927
928=item L<AnyEvent::GPSD> 928=item L<AnyEvent::GPSD>
929 929
930A non-blocking interface to gpsd, a daemon delivering GPS information. 930A non-blocking interface to gpsd, a daemon delivering GPS information.
931 931
932=item L<AnyEvent::IRC>
933
934AnyEvent based IRC client module family (replacing the older Net::IRC3).
935
936=item L<AnyEvent::XMPP>
937
938AnyEvent based XMPP (Jabber protocol) module family (replacing the older
939Net::XMPP2>.
940
932=item L<AnyEvent::IGS> 941=item L<AnyEvent::IGS>
933 942
934A non-blocking interface to the Internet Go Server protocol (used by 943A non-blocking interface to the Internet Go Server protocol (used by
935L<App::IGS>). 944L<App::IGS>).
936 945
937=item L<AnyEvent::IRC>
938
939AnyEvent based IRC client module family (replacing the older Net::IRC3).
940
941=item L<Net::XMPP2>
942
943AnyEvent based XMPP (Jabber protocol) module family.
944
945=item L<Net::FCP> 946=item L<Net::FCP>
946 947
947AnyEvent-based implementation of the Freenet Client Protocol, birthplace 948AnyEvent-based implementation of the Freenet Client Protocol, birthplace
948of AnyEvent. 949of AnyEvent.
949 950
952High level API for event-based execution flow control. 953High level API for event-based execution flow control.
953 954
954=item L<Coro> 955=item L<Coro>
955 956
956Has special support for AnyEvent via L<Coro::AnyEvent>. 957Has special support for AnyEvent via L<Coro::AnyEvent>.
957
958=item L<IO::Lambda>
959
960The lambda approach to I/O - don't ask, look there. Can use AnyEvent.
961 958
962=back 959=back
963 960
964=cut 961=cut
965 962
1123# allow only one watcher per fd, so we dup it to get a different one). 1120# allow only one watcher per fd, so we dup it to get a different one).
1124sub _dupfh($$;$$) { 1121sub _dupfh($$;$$) {
1125 my ($poll, $fh, $r, $w) = @_; 1122 my ($poll, $fh, $r, $w) = @_;
1126 1123
1127 # cygwin requires the fh mode to be matching, unix doesn't 1124 # cygwin requires the fh mode to be matching, unix doesn't
1128 my ($rw, $mode) = $poll eq "r" ? ($r, "<") 1125 my ($rw, $mode) = $poll eq "r" ? ($r, "<") : ($w, ">");
1129 : $poll eq "w" ? ($w, ">")
1130 : Carp::croak "AnyEvent->io requires poll set to either 'r' or 'w'";
1131 1126
1132 open my $fh2, "$mode&" . fileno $fh 1127 open my $fh2, "$mode&", $fh
1133 or die "cannot dup() filehandle: $!,"; 1128 or die "AnyEvent->io: cannot dup() filehandle in mode '$poll': $!,";
1134 1129
1135 # we assume CLOEXEC is already set by perl in all important cases 1130 # we assume CLOEXEC is already set by perl in all important cases
1136 1131
1137 ($fh2, $rw) 1132 ($fh2, $rw)
1138} 1133}
1482=item C<PERL_ANYEVENT_RESOLV_CONF> 1477=item C<PERL_ANYEVENT_RESOLV_CONF>
1483 1478
1484The file to use instead of F</etc/resolv.conf> (or OS-specific 1479The file to use instead of F</etc/resolv.conf> (or OS-specific
1485configuration) in the default resolver. When set to the empty string, no 1480configuration) in the default resolver. When set to the empty string, no
1486default config will be used. 1481default config will be used.
1482
1483=item C<PERL_ANYEVENT_CA_FILE>, C<PERL_ANYEVENT_CA_PATH>.
1484
1485When neither C<ca_file> nor C<ca_path> was specified during
1486L<AnyEvent::TLS> context creation, and either of these environment
1487variables exist, they will be used to specify CA certificate locations
1488instead of a system-dependent default.
1487 1489
1488=back 1490=back
1489 1491
1490=head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE 1492=head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE
1491 1493
2114L<Glib>, L<Tk>, L<Event::Lib>, L<Qt>, L<POE>. 2116L<Glib>, L<Tk>, L<Event::Lib>, L<Qt>, L<POE>.
2115 2117
2116Implementations: L<AnyEvent::Impl::EV>, L<AnyEvent::Impl::Event>, 2118Implementations: L<AnyEvent::Impl::EV>, L<AnyEvent::Impl::Event>,
2117L<AnyEvent::Impl::Glib>, L<AnyEvent::Impl::Tk>, L<AnyEvent::Impl::Perl>, 2119L<AnyEvent::Impl::Glib>, L<AnyEvent::Impl::Tk>, L<AnyEvent::Impl::Perl>,
2118L<AnyEvent::Impl::EventLib>, L<AnyEvent::Impl::Qt>, 2120L<AnyEvent::Impl::EventLib>, L<AnyEvent::Impl::Qt>,
2119L<AnyEvent::Impl::POE>. 2121L<AnyEvent::Impl::POE>, L<AnyEvent::Impl::IOAsync>.
2120 2122
2121Non-blocking file handles, sockets, TCP clients and 2123Non-blocking file handles, sockets, TCP clients and
2122servers: L<AnyEvent::Handle>, L<AnyEvent::Socket>. 2124servers: L<AnyEvent::Handle>, L<AnyEvent::Socket>, L<AnyEvent::TLS>.
2123 2125
2124Asynchronous DNS: L<AnyEvent::DNS>. 2126Asynchronous DNS: L<AnyEvent::DNS>.
2125 2127
2126Coroutine support: L<Coro>, L<Coro::AnyEvent>, L<Coro::EV>, L<Coro::Event>, 2128Coroutine support: L<Coro>, L<Coro::AnyEvent>, L<Coro::EV>,
2129L<Coro::Event>,
2127 2130
2128Nontrivial usage examples: L<Net::FCP>, L<Net::XMPP2>, L<AnyEvent::DNS>. 2131Nontrivial usage examples: L<AnyEvent::GPSD>, L<AnyEvent::XMPP>,
2132L<AnyEvent::HTTP>.
2129 2133
2130 2134
2131=head1 AUTHOR 2135=head1 AUTHOR
2132 2136
2133 Marc Lehmann <schmorp@schmorp.de> 2137 Marc Lehmann <schmorp@schmorp.de>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines