home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeJava and XSLTSearch this book

8.131. IO::Select

Implements an object-oriented approach to the system select function call. Allows the user to see which I/O handles are ready for reading, writing, or have an error condition pending.

new

new $s = IO::Select->new([handles])

Constructor. Creates a new object and optionally initializes it with a set of handles.

add

$s->add(handles)

Adds list of handles to the IO::Select object, to be returned when an event occurs. IO::Select keeps the list of handles in a cache, which is indexed by the handle's file number. Each handle can be an IO::Handle object, an integer, or a reference to an array, in which the first element is an IO::Handle object or an integer.

bits

$s->bits(  )

Returns the bit string that is suitable for use as an argument to the core select call.

can_read

$s->can_read([timeout])

Returns array of handles that are ready for reading. timeout is the maximum amount of time to wait before returning an empty list. If timeout is not given, and any handles are registered, then the call blocks.

can_write

$s->can_write([timeout])

Same as can_read, but checks for handles that can be written to.

count

$s->count(  )

Returns the number of handles that the object checks for when one of the can_ methods is called or the object is passed to the select static method.

exists

$s->exists(handle)

Returns the handle if it is present; otherwise, returns undef.

handles

$s->handles

Returns an array of all registered handles.

has_error

$s->has_error([timeout])

Same as can_read, but checks for handles that have an error condition.

remove

$s->remove(handles)

Removes all the given handles from the object, locating them by file number.

select

$s->select(read, write, error[, timeout])

Static method. Call it with the package name as with new. read, write, and error are either undef or IO::Select objects. The optional argument timeout has the same effect as for the core select call.

Returns an array of three elements, each a reference to an array or an empty array on error. The arrays hold the handles that are ready for reading, ready for writing, and have error conditions, respectively.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.