NAME

IOMux::Handler::Write - any mux writer

INHERITANCE

IOMux::Handler::Write
  is an IOMux::Handler

IOMux::Handler::Write is extended by
  IOMux::Bundle
  IOMux::File::Write
  IOMux::Net::TCP
  IOMux::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.

Extends "DESCRIPTION" in IOMux::Handler.

METHODS

Extends "METHODS" in IOMux::Handler.

Constructors

Extends "Constructors" in IOMux::Handler.

IOMux::Handler::Write->new(%options)
-Option    --Defined in     --Default
 fh          IOMux::Handler   <required>
 name        IOMux::Handler   <stringified handle>
 write_size                   4096
fh => FILEHANDLE
name => STRING
write_size => INTEGER
IOMux::Handler::Write->open($mode, $what, %options)

Inherited, see "Constructors" in IOMux::Handler

Accessors

Extends "Accessors" in IOMux::Handler.

$obj->fh()

Inherited, see "Accessors" in IOMux::Handler

$obj->fileno()

Inherited, see "Accessors" in IOMux::Handler

$obj->mux()

Inherited, see "Accessors" in IOMux::Handler

$obj->name()

Inherited, see "Accessors" in IOMux::Handler

$obj->usesSSL()

Inherited, see "Accessors" in IOMux::Handler

$obj->writeSize( [$integer] )

The number of bytes written at each write.

User interface

Extends "User interface" in IOMux::Handler.

Connection

Extends "Connection" in IOMux::Handler.

$obj->close( [$callback] )

Inherited, see "Connection" in IOMux::Handler

$obj->timeout( [$timeout] )

Inherited, see "Connection" in IOMux::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

Extends "Multiplexer" in IOMux::Handler.

Connection

Extends "Connection" in IOMux::Handler.

$obj->muxInit( $mux, [$handler] )

Inherited, see "Connection" in IOMux::Handler

$obj->muxRemove()

Inherited, see "Connection" in IOMux::Handler

$obj->muxTimeout()

Inherited, see "Connection" in IOMux::Handler

Reading

Extends "Reading" in IOMux::Handler.

$obj->muxExceptFlagged($fileno)

Inherited, see "Reading" in IOMux::Handler

$obj->muxReadFlagged($fileno)

Inherited, see "Reading" in IOMux::Handler

Writing

Extends "Writing" in IOMux::Handler.

$obj->muxOutbufferEmpty()

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 'IOMux::Net::TCP';

sub muxOutbufferEmpty()
{   my $self = shift;
    if(my $data = $self->produce_more_data)
    {   $self->write(\$data);
    }
    else
    {   $self->SUPER::muxOutbufferEmpty;
    }
}
$obj->muxOutputWaiting()

Returns true is there is output queued.

$obj->muxWriteFlagged($fileno)

Inherited, see "Writing" in IOMux::Handler

Service

Extends "Service" in IOMux::Handler.

Helpers

Extends "Helpers" in IOMux::Handler.

$obj->extractSocket(HASH)
IOMux::Handler::Write->extractSocket(HASH)

Inherited, see "Helpers" in IOMux::Handler

$obj->fdset($state, $read, $write, $error)

Inherited, see "Helpers" in IOMux::Handler

$obj->show()

Inherited, see "Helpers" in IOMux::Handler

SEE ALSO

This module is part of IOMux distribution version 1.01, built on January 15, 2020. Website: http://perl.overmeer.net/CPAN

LICENSE

Copyrights 2011-2020 by [Mark Overmeer <markov@cpan.org>]. 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://dev.perl.org/licenses/