NAME
IO::Mux::Handler::Write - any mux writer
INHERITANCE
IO::Mux::Handler::Write
is a IO::Mux::Handler
IO::Mux::Handler::Write is extended by
IO::Mux::Bundle
IO::Mux::File::Write
IO::Mux::Net::TCP
IO::Mux::Pipe::Write
SYNOPSIS
# only use extensions
DESCRIPTION
In an event driven program, you must be careful with every Operation System call, because it can block the event mechanism, hence the program as a whole. Often you can be lazy with writes, because its communication buffers are usually working quite asynchronous... but not always. You may skip the callbacks for small writes and prints.
METHODS
Constructors
- IO::Mux::Handler::Write->new(OPTIONS)
-
-Option --Defined in --Default fh IO::Mux::Handler <required> name IO::Mux::Handler <stringified handle> write_size 4096
- IO::Mux::Handler::Write->open(MODE, WHAT, OPTIONS) See "Constructors" in IO::Mux::Handler
Accessors
- $obj->fh See "Accessors" in IO::Mux::Handler
- $obj->fileno See "Accessors" in IO::Mux::Handler
- $obj->mux See "Accessors" in IO::Mux::Handler
- $obj->name See "Accessors" in IO::Mux::Handler
- $obj->usesSSL See "Accessors" in IO::Mux::Handler
- $obj->writeSize([INTEGER])
-
The number of bytes written at each write.
User interface
Connection
- $obj->close([CALLBACK]) See "Connection" in IO::Mux::Handler
- $obj->timeout([TIMEOUT]) See "Connection" in IO::Mux::Handler
Writing
- $obj->print(STRING|SCALAR|LIST|ARRAY)
-
Send one or more lines to the output. The data is packed into a single string first. The ARRAY (of strings) and SCALAR (ref string) choices are available for efficiency.
example:
$conn->print($some_text); $conn->print(\$some_text); my $fh = $conn->fh; print $fh "%s%d%X", $foo, $bar, $baz;
- $obj->printf(FORMAT, PARAMS)
-
example:
$conn->printf("%s%d%X", $foo, $bar, $baz); my $fh = $conn->fh; $fh->printf("%s%d%X", $foo, $bar, $baz);
- $obj->say(STRING|SCALAR|LIST|ARRAY)
-
Like print() but adding a newline at the end.
- $obj->write(SCALAR, [MORE])
-
Send the content of the string, passed as reference in SCALAR. You probably want to use print() or printf(). You may provide a code reference to produce MORE info when the output buffer get empty.
Multiplexer
Connection
- $obj->mux_init(MUX, [HANDLER]) See "Connection" in IO::Mux::Handler
- $obj->mux_remove See "Connection" in IO::Mux::Handler
- $obj->mux_timeout See "Connection" in IO::Mux::Handler
Reading
- $obj->mux_except_flagged(FILENO) See "Reading" in IO::Mux::Handler
- $obj->mux_read_flagged(FILENO) See "Reading" in IO::Mux::Handler
Writing
- $obj->mux_outbuffer_empty
-
Called after all pending output has been written to the file descriptor. You may use this callback to produce more data to be written.
When this method is not overruled, the multiplexer will stop listening to the write flag until an explicit write() gets executed.
example:
package My::Service; use base 'IO::Mux::Net::TCP'; sub mux_outbuffer_empty() { my $self = shift; if(my $data = $self->produce_more_data) { $self->write(\$data); } else { $self->SUPER::mux_outbuffer_empty; } }
- $obj->mux_output_waiting
-
Returns true is there is output queued.
- $obj->mux_write_flagged(FILENO) See "Writing" in IO::Mux::Handler
Service
Helpers
- $obj->extractSocket(HASH)
- IO::Mux::Handler::Write->extractSocket(HASH) See "Helpers" in IO::Mux::Handler
- $obj->fdset(STATE, READ, WRITE, ERROR) See "Helpers" in IO::Mux::Handler
- $obj->show See "Helpers" in IO::Mux::Handler
SEE ALSO
This module is part of IO-Mux distribution version 0.11, built on January 26, 2011. Website: http://perl.overmeer.net/ All modules in this suite: "Any::Daemon", "IO::Mux", and "IO::Mux::HTTP".
Please post questions or ideas to perl@overmeer.net
LICENSE
Copyrights 2011 by Mark Overmeer. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html