… | |
… | |
176 | =head2 I/O WATCHERS |
176 | =head2 I/O WATCHERS |
177 | |
177 | |
178 | You can create an I/O watcher by calling the C<< AnyEvent->io >> method |
178 | You can create an I/O watcher by calling the C<< AnyEvent->io >> method |
179 | with the following mandatory key-value pairs as arguments: |
179 | with the following mandatory key-value pairs as arguments: |
180 | |
180 | |
181 | C<fh> is the Perl I<file handle> (I<not> file descriptor) to watch |
181 | C<fh> is the Perl I<file handle> (or a naked file descriptor) to watch |
182 | for events (AnyEvent might or might not keep a reference to this file |
182 | for events (AnyEvent might or might not keep a reference to this file |
183 | handle). Note that only file handles pointing to things for which |
183 | handle). Note that only file handles pointing to things for which |
184 | non-blocking operation makes sense are allowed. This includes sockets, |
184 | non-blocking operation makes sense are allowed. This includes sockets, |
185 | most character devices, pipes, fifos and so on, but not for example files |
185 | most character devices, pipes, fifos and so on, but not for example files |
186 | or block devices. |
186 | or block devices. |
… | |
… | |
968 | no warnings; |
968 | no warnings; |
969 | use strict qw(vars subs); |
969 | use strict qw(vars subs); |
970 | |
970 | |
971 | use Carp; |
971 | use Carp; |
972 | |
972 | |
973 | our $VERSION = 4.45; |
973 | our $VERSION = 4.8; |
974 | our $MODEL; |
974 | our $MODEL; |
975 | |
975 | |
976 | our $AUTOLOAD; |
976 | our $AUTOLOAD; |
977 | our @ISA; |
977 | our @ISA; |
978 | |
978 | |
… | |
… | |
1123 | # allow only one watcher per fd, so we dup it to get a different one). |
1123 | # allow only one watcher per fd, so we dup it to get a different one). |
1124 | sub _dupfh($$;$$) { |
1124 | sub _dupfh($$;$$) { |
1125 | my ($poll, $fh, $r, $w) = @_; |
1125 | my ($poll, $fh, $r, $w) = @_; |
1126 | |
1126 | |
1127 | # cygwin requires the fh mode to be matching, unix doesn't |
1127 | # cygwin requires the fh mode to be matching, unix doesn't |
1128 | my ($rw, $mode) = $poll eq "r" ? ($r, "<") |
1128 | 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 | |
1129 | |
1132 | open my $fh2, "$mode&" . fileno $fh |
1130 | open my $fh2, "$mode&", $fh |
1133 | or die "cannot dup() filehandle: $!,"; |
1131 | or die "AnyEvent->io: cannot dup() filehandle in mode '$poll': $!,"; |
1134 | |
1132 | |
1135 | # we assume CLOEXEC is already set by perl in all important cases |
1133 | # we assume CLOEXEC is already set by perl in all important cases |
1136 | |
1134 | |
1137 | ($fh2, $rw) |
1135 | ($fh2, $rw) |
1138 | } |
1136 | } |
… | |
… | |
1470 | |
1468 | |
1471 | =item C<PERL_ANYEVENT_MAX_FORKS> |
1469 | =item C<PERL_ANYEVENT_MAX_FORKS> |
1472 | |
1470 | |
1473 | The maximum number of child processes that C<AnyEvent::Util::fork_call> |
1471 | The maximum number of child processes that C<AnyEvent::Util::fork_call> |
1474 | will create in parallel. |
1472 | will create in parallel. |
|
|
1473 | |
|
|
1474 | =item C<PERL_ANYEVENT_MAX_OUTSTANDING_DNS> |
|
|
1475 | |
|
|
1476 | The default value for the C<max_outstanding> parameter for the default DNS |
|
|
1477 | resolver - this is the maximum number of parallel DNS requests that are |
|
|
1478 | sent to the DNS server. |
|
|
1479 | |
|
|
1480 | =item C<PERL_ANYEVENT_RESOLV_CONF> |
|
|
1481 | |
|
|
1482 | The file to use instead of F</etc/resolv.conf> (or OS-specific |
|
|
1483 | configuration) in the default resolver. When set to the empty string, no |
|
|
1484 | default config will be used. |
|
|
1485 | |
|
|
1486 | =item C<PERL_ANYEVENT_CA_FILE>, C<PERL_ANYEVENT_CA_PATH>. |
|
|
1487 | |
|
|
1488 | When neither C<ca_file> nor C<ca_path> was specified during |
|
|
1489 | L<AnyEvent::TLS> context creation, and either of these environment |
|
|
1490 | variables exist, they will be used to specify CA certificate locations |
|
|
1491 | instead of a system-dependent default. |
1475 | |
1492 | |
1476 | =back |
1493 | =back |
1477 | |
1494 | |
1478 | =head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE |
1495 | =head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE |
1479 | |
1496 | |