IO::Mux::Handle - Virtual handle used with the IO::Mux multiplexer.
use IO::Mux ; my $mux = new IO::Mux(\*SOCKET) ; my $iomh = new IO::Mux::Handle($mux) ; open($iomh, "identifier") or die("Can't open: " . $io->get_error()) ; print $iomh "hello\n" ; while (<$iomh>){ print $_ ; } close($iomh) ;
IO::Mux::Handle objects are used to create virtual handles that are multiplexed through an IO::Mux object.
IO::Mux::Handle
Creates a new IO::Mux::Handle that is multiplexed over the real handle managed by IOMUX.
Since IO::Mux::Handle extends IO::Handle, most IO::Handle methods that make sense in this context are supported. The corresponding builtins can also be used. Errors are reported using the standard return values and mechanisms. See below ("ERROR REPORTING" in IO::Mux::Handle) for more details.
Opens $iomh and associates it with the identifier ID. ID can be any scalar value, but any tabs ('\t') in ID will be replaced by spaces (' ') in order to make it compatible with the underlying multiplexing protocol.
Returns 1 on success or undef on error (the error message can be retreived by calling $iomh->get_error()).
Since there is no real filehandle associated with IO::Mux::Handle objects, $iomh->fileno() returns the ID identifier that was passed to $iomh->open().
Returns the last error associated with $iomh.
While manipulating IO::Mux::Handle objects, two types of errors can occur:
When error occurs on the underlying (real) handle, $! is set as usual and the approriate return code is used.
IO::Mux::*
Sometimes errors can be generated by the IO::Mux:* code itself. In this case, $! is set to EIO if possible (see Errno for more details). If EIO does not exists on your system, $! is set to 99999. Also, the actual IO::Mux::* error message can be retrieved by calling $iomh->get_error().
IO::Mux:*
EIO
Therefore, when working with IO::Mux::Handle objects, it is always a good idea to check $iomh->get_error() when $! is supposed to be set, i.e.:
print $iomh "hi!\n" or die("Can't print: $! (" . $iomh->get_error() . ")") ;
IO::Handle, IO::Mux
Patrick LeBoutillier, <patl@cpan.org>
Copyright (C) 2005 by Patrick LeBoutillier
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.
To install IO::Mux, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Mux
CPAN shell
perl -MCPAN -e shell install IO::Mux
For more information on module installation, please visit the detailed CPAN module installation guide.