SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG
DONATE


YUM REPOSITORY

 
 

MAN page from CentOS 8 perl-IO-1.40-452.module_el8.4.0+646+45e06e4a.x86_64.rpm

IO::Select

Section: Perl Programmers Reference Guide (3pm)
Updated: 2019-10-24
Index 

NAME

IO::Select - OO interface to the select system call 

SYNOPSIS

    use IO::Select;    $s = IO::Select->new();    $s->add(\*STDIN);    $s->add($some_handle);    @ready = $s->can_read($timeout);    @ready = IO::Select->new(@handles)->can_read(0);
 

DESCRIPTION

The "IO::Select" package implements an object approach to the system "select"function call. It allows the user to see what IO handles, see IO::Handle,are ready for reading, writing or have an exception pending. 

CONSTRUCTOR

new ( [ HANDLES ] )
The constructor creates a new object and optionally initialises it with a setof handles.
 

METHODS

add ( HANDLES )
Add the list of handles to the "IO::Select" object. It is these values thatwill be returned when an event occurs. "IO::Select" keeps these values in acache which is indexed by the "fileno" of the handle, so if more than onehandle with the same "fileno" is specified then only the last one is cached.

Each handle can be an "IO::Handle" object, an integer or an arrayreference where the first element is an "IO::Handle" or an integer.

remove ( HANDLES )
Remove all the given handles from the object. This method also worksby the "fileno" of the handles. So the exact handles that were addedneed not be passed, just handles that have an equivalent "fileno"
exists ( HANDLE )
Returns a true value (actually the handle itself) if it is present.Returns undef otherwise.
handles
Return an array of all registered handles.
can_read ( [ TIMEOUT ] )
Return an array of handles that are ready for reading. "TIMEOUT" is themaximum amount of time to wait before returning an empty list (with $!unchanged), in seconds, possibly fractional. If "TIMEOUT" is not givenand any handles are registered then the call will block indefinitely.Upon error, an empty list is returned, with $! set to indicate theerror. To distinguish between timeout and error, set $! to zerobefore calling this method, and check it after an empty list is returned.
can_write ( [ TIMEOUT ] )
Same as "can_read" except check for handles that can be written to.
has_exception ( [ TIMEOUT ] )
Same as "can_read" except check for handles that have an exceptioncondition, for example pending out-of-band data.
count ()
Returns the number of handles that the object will check for whenone of the "can_" methods is called or the object is passed tothe "select" static method.
bits()
Return the bit string suitable as argument to the core select() call.
select ( READ, WRITE, EXCEPTION [, TIMEOUT ] )
"select" is a static method, that is you call it with the package namelike "new". "READ", "WRITE" and "EXCEPTION" are either "undef" or"IO::Select" objects. "TIMEOUT" is optional and has the same effect asfor the core select call.

If at least one handle is ready for the specified kind of operation,the result will be an array of 3 elements, each a reference to an arraywhich will hold the handles that are ready for reading, writing andhave exceptions respectively. Upon timeout, an empty list is returned,with $! unchanged. Upon error, an empty list is returned, with $!set to indicate the error. To distinguish between timeout and error,set $! to zero before calling this method, and check it after anempty list is returned.

 

EXAMPLE

Here is a short example which shows how "IO::Select" could be usedto write a server which communicates with several sockets while alsolistening for more connections on a listen socket

    use IO::Select;    use IO::Socket;    $lsn = IO::Socket::INET->new(Listen => 1, LocalPort => 8080);    $sel = IO::Select->new( $lsn );    while(@ready = $sel->can_read) {        foreach $fh (@ready) {            if($fh == $lsn) {                # Create a new socket                $new = $lsn->accept;                $sel->add($new);            }            else {                # Process socket                # Maybe we have finished with the socket                $sel->remove($fh);                $fh->close;            }        }    }
 

AUTHOR

Graham Barr. Currently maintained by the Perl Porters. Please report allbugs to <perlbugAATTperl.org>. 

COPYRIGHT

Copyright (c) 1997-8 Graham Barr <gbarrAATTpobox.com>. All rights reserved.This program is free software; you can redistribute it and/ormodify it under the same terms as Perl itself.


 

Index

NAME
SYNOPSIS
DESCRIPTION
CONSTRUCTOR
METHODS
EXAMPLE
AUTHOR
COPYRIGHT

This document was created byman2html,using the manual pages.