Mark Overmeer > IOMux > IOMux::Handler::Write

Download:
IOMux-0.13.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.13   Source  

NAME ^

IOMux::Handler::Write - any mux writer

INHERITANCE ^

 IOMux::Handler::Write
   is a 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->mux_init( MUX, [HANDLER] )

Inherited, see "Connection" in IOMux::Handler

$obj->mux_remove()

Inherited, see "Connection" in IOMux::Handler

$obj->mux_timeout()

Inherited, see "Connection" in IOMux::Handler

Reading

Extends "Reading" in IOMux::Handler.

$obj->mux_except_flagged(FILENO)

Inherited, see "Reading" in IOMux::Handler

$obj->mux_read_flagged(FILENO)

Inherited, see "Reading" in IOMux::Handler

Writing

Extends "Writing" in IOMux::Handler.

$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 'IOMux::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)

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 0.13, built on July 21, 2015. Website: http://perl.overmeer.net/ All modules in this suite: "Any::Daemon", "IOMux", and "IOMux::HTTP".

Please post questions or ideas to perl@overmeer.net

LICENSE ^

Copyrights 2011-2015 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

syntax highlighting: