IO::Select
Native Rust implementation built into the interpreter. Runtime: PP. See original documentation for the full Perl reference.
Provides multiplexed I/O via the POSIX select() system call, compatible with Perl’s IO::Select module.
IO::Select objects are blessed hashrefs internally storing:
__fds: an Av mapping fd_number -> stored handle (the original Sv)__count: integer count of registered handles
Functions
add
Adds one or more handles to the select set. Returns the number of handles added.
$sel->add($fh);
$sel->add(\*STDIN, $sock);
bits
Returns the vec-style bitmask string suitable for the 4-argument
select() builtin. Returns undef if the set is empty.
my $bits = $sel->bits();
can_read
Returns a list of handles that are ready for reading within the given timeout (seconds, fractional allowed).
my @ready = $sel->can_read(0.5);
can_write
Returns a list of handles that are ready for writing within the given timeout.
my @ready = $sel->can_write(1.0);
count
Returns the number of handles currently registered.
my $n = $sel->count();
exists
Checks if a given handle is in the select set. Returns the stored handle if present, undef otherwise.
if (defined $sel->exists($fh)) { ... }
handles
Returns a list of all registered handles.
my @fhs = $sel->handles();
has_exception
Returns a list of handles that have pending exceptions within the given timeout.
my @exc = $sel->has_exception(0);
new
Constructor. Creates an IO::Select object, optionally pre-populated with an initial set of handles.
use IO::Select;
my $sel = IO::Select->new();
my $sel = IO::Select->new($fh1, $fh2);
remove
Removes one or more handles from the select set. Returns the number of handles removed.
$sel->remove($fh);
select
Static/class method. Performs a POSIX select(2) across up to three
IO::Select objects (readers, writers, errors) with a timeout.
Returns three arrayrefs of ready handles, or an empty list on timeout.
my ($r, $w, $e) = IO::Select->select($readers, $writers, $errors, $timeout);