IO::Mux::Handler::Read - any mux reader


IO-Mux documentation  | view source Contained in the IO-Mux distribution.

Index


NAME

Top

IO::Mux::Handler::Read - any mux reader

INHERITANCE

Top

 IO::Mux::Handler::Read
   is a IO::Mux::Handler

 IO::Mux::Handler::Read is extended by
   IO::Mux::Bundle
   IO::Mux::File::Read
   IO::Mux::Net::TCP
   IO::Mux::Pipe::Read

SYNOPSIS

Top

  # only use extensions

DESCRIPTION

Top

This base-class defines the interface which every reader offers.

METHODS

Top

Constructors

IO::Mux::Handler::Read->new(OPTIONS)
 -Option   --Defined in     --Default
  fh         IO::Mux::Handler  <required>
  name       IO::Mux::Handler  <stringified handle>
  read_size                   32768

fh => FILEHANDLE
name => STRING
read_size => INTEGER

IO::Mux::Handler::Read->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->readSize([INTEGER])

The number of bytes requested at each read.

$obj->usesSSL See "Accessors" in IO::Mux::Handler

User interface

Connection

$obj->close([CALLBACK]) See "Connection" in IO::Mux::Handler
$obj->timeout([TIMEOUT]) See "Connection" in IO::Mux::Handler

Reading

$obj->readline(CALLBACK)

Read a single line (bytes upto a LF or CRLF). After the whole line has arrived, the CALLBACK will be invoked with the received line as parameter. that line is terminated by a LF (\n), even when the file contains CRLF or CR endings.

At end of file, the last fragment will be returned.

$obj->slurp(CALLBACK)

Read all remaining data from a resource. After everything has been read, it will be returned as SCALAR (string reference)

example:

  my $pwd  = $mux->open('<', '/etc/passwd');
  my $data = $pwd->slurp;
  my $size = length $$data;

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_eof(INPUT)

This is called when an end-of-file condition is present on the handle. Like mux_input(), it is also passed a reference to the input buffer. You should consume the entire buffer or else it will just be lost.

$obj->mux_except_flagged(FILENO) See "Reading" in IO::Mux::Handler
$obj->mux_input(BUFFER)

Called when new input has arrived on the input. It is passed a reference to the input BUFFER. It must remove any input that it you have consumed from the BUFFER, and leave any partially received data in there.

example:

  sub mux_input
  {   my ($self, $inbuf) = @_;

      # Process each whole line in the input, leaving partial
      # lines in the input buffer for more.
      while($$inbuf =~ s/^(.*?)\r?\n// )
      {   $self->process_command($1);
      }
  }

$obj->mux_read_flagged(FILENO) See "Reading" in IO::Mux::Handler

Writing

$obj->mux_write_flagged(FILENO) See "Writing" in IO::Mux::Handler

Service

Helpers

$obj->extractSocket(HASH)
IO::Mux::Handler::Read->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

Top

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

Top

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


IO-Mux documentation  | view source Contained in the IO-Mux distribution.