Asynchat

 view release on metacpan or  search on metacpan

lib/Asynchat.pm  view on Meta::CPAN


our $ac_in_buffer_size = 4096;
our $ac_out_buffer_size = 4096;

sub init {
    my($self, $sock, $map) = @_;

    $self->{_ac_in_buffer} = '';
    $self->{_incoming} = [];
    $self->{_producer_fifo} = []; # a list of data;
    $self->SUPER::init($sock, $map);
    
    return $self;
}

sub collect_incoming_data {
    # overrided
}

sub _collect_incoming_data {
    my($self, $data) = @_;

script/EchoClient.pm  view on Meta::CPAN

use warnings;

use base qw( Asynchat );

sub init {
    my($self, $addr, $port, $family, $type, $message) = @_;

    $self->{_message} = $message; 
    $self->{_received_data} = [];

    $self->SUPER::init();

    if (not $port) {
        $port = 37;
    }

    $self->create_socket($addr, $family, $type);
    $self->connect($addr, $port);
}

sub handle_connect {

script/EchoHandler.pm  view on Meta::CPAN


use strict;
use warnings;

use base qw( Asynchat );

sub init {
    my($self, $sock) = @_;

    $self->{_received_data} = [];
    $self->SUPER::init($sock);

    # start looking for the ECHO command
    $self->{_process_command} = 1;
    $self->set_terminator('\n');
    
    return $self;
}

sub collect_incoming_data {
    my($self, $data) = @_;

script/EchoServer.pm  view on Meta::CPAN

use strict;
use warnings;

use Asyncore;
use EchoHandler;
use base qw( Asyncore::Dispatcher );

sub init {
    my($self, $port, $family, $type) = @_;

    $self->SUPER::init();

    if (not $port) {
        $port = 37;
    }

    $self->create_socket($family, $type);
    $self->bind(35000);
    $self->listen(5);
}



( run in 0.496 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )