Carrot
view release on metacpan or search on metacpan
lib/Carrot/Continuity/Coordination/Episode/Paragraph/TCP_Socket_IO.pm view on Meta::CPAN
use strict;
use warnings 'FATAL' => 'all';
use bytes;
use POSIX qw(:errno_h);
use IO::SendFile;
my $expressiveness = Carrot::individuality;
$expressiveness->provide(
my $class_names = '::Individuality::Controlled::Class_Names',
my $loop = '::Continuity::Coordination::Episode::Loop',
my $customized_settings = '::Individuality::Controlled::Customized_Settings');
$customized_settings->provide_plain_value(
my $sysread_size = 'sysread_size',
my $syswrite_size = 'syswrite_size',
my $maximum_error_retries = 'maximum_error_retries');
$class_names->provide(
'[=project_pkg=]::Paragraph::TCP_Socket_IO::Buffer::',
my $input_buffer_class = '::Input',
my $output_buffer_class = '::Output');
# =--------------------------------------------------------------------------= #
sub INOUT_STOP() { -1 }
sub INOUT_NOCHANGE() { 0 }
sub INOUT_START() { 1 }
sub BUF_CONTENT() { 0 };
sub BUF_OFFSET() { 1 };
sub BUF_LEFT() { 2 };
sub BUF_IS_FILE() { 3 };
$OS_SIGNALS{'PIPE'} = 'IGNORE'; # enables EPIPE globally to avoid sysaction() flooding
# =--------------------------------------------------------------------------= #
sub attribute_construction
# /type method
# /effect "Constructs the attribute(s) of a newly created instance."
# //parameters
# socket
# io_timeout
# protocol
# //returns
{
my ($this, $socket, $io_timeout, $protocol) = @ARGUMENTS;
$this->[ATR_SOCKET] = $socket;
my $fd_nonstop_io = $loop->construct_standard_episode(
'::Target::FD_Nonstop_IO', $this, $socket);
$fd_nonstop_io->activate;
$fd_nonstop_io->fd_watch_read;
$this->[ATR_TARGET] = $fd_nonstop_io;
$this->[ATR_INPUT] = $input_buffer_class->indirect_constructor($protocol);
$this->[ATR_OUTPUT] = $output_buffer_class->indirect_constructor;
$this->[ATR_TIMEOUT] = $loop->construct_standard_episode(
'::Target::Timeout', $this, $io_timeout);
$this->[ATR_TIMEOUT]->activate;
return;
}
sub poll_input_buffer
# /type method
# /effect ""
# //parameters
# //returns
# ?
{
my ($this) = @ARGUMENTS;
return(IS_UNDEFINED) if ($this->[ATR_OUTPUT]->is_closed);
$this->pause_input($this->[ATR_INPUT]->process_data(IS_FALSE));
return($this->[ATR_INPUT]->has_data);
}
sub close_buffers
# /type method
# /effect ""
# //parameters
# //returns
{
my ($this) = @ARGUMENTS;
$this->[ATR_TARGET]->fd_ignore_read;
$this->[ATR_TARGET]->fd_ignore_write;
$this->[ATR_INPUT]->close;
$this->[ATR_OUTPUT]->close;
return;
}
sub evt_time_timeout
# /type method
# /effect ""
# //parameters
# //returns
{
my ($this) = @ARGUMENTS;
return unless (defined($this->[ATR_SOCKET]));
$this->close_buffers;
$this->[ATR_TIMEOUT]->deactivate;
$this->[ATR_TARGET]->deactivate;
my $fd = fileno($this->[ATR_SOCKET]);
POSIX::close($fd) || warn("FD$fd: close: $OS_ERROR");
$this->[ATR_SOCKET] = IS_UNDEFINED;
return;
}
sub evt_fd_nonstop_validate_fh
# /type method
# /effect ""
# //parameters
# //returns
{}; # not implemented, yet
( run in 3.377 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )