AnyEvent-Connection
view release on metacpan or search on metacpan
xt/01-test.t view on Meta::CPAN
#!/usr/bin/env perl
BEGIN {
print "1..0 # SKIP: Currrently broken\n";
exit 0;
}
use common::sense;
use lib::abs '../lib';
use Devel::Rewrite;
BEGIN {$ENV{DEBUG_CB} = 1}
package Echo::Client;
use base 'AnyEvent::Connection';
package main;
use Test::TCP;
use AnyEvent::Impl::Perl;
use AnyEvent;
use AnyEvent::Socket;
use Test::More tests => 22;
use Test::NoWarnings;
diag "Testing AnyEvent::Connection $AnyEvent::Connection::VERSION $INC{'AnyEvent/Connection.pm'}";
my $cv = AnyEvent->condvar;
$SIG{ALRM} = sub { $cv->send; die "Alarm clock"; };
alarm 10;
test_tcp(
server => sub {
my $port = shift;
diag "$$: sr $port";
my $count;
my %st;
$st{server} = tcp_server undef,$port, sub {
#warn "got conn @_";
my $h = AnyEvent::Handle->new(
fh => $_[0],
);
$h->on_error(sub{ $h->destroy; undef $h; });
$h->push_read(line => sub {
shift;
if ($_[0] =~ /reset/) {
diag "Initiating connection reset";
#$h->push_write("some shit \n");
$h->destroy;
undef $h;
%st = ();
$st{server} = tcp_server undef,$port, sub {
#warn "got new conn @_";
};
}
});
};
$cv->recv;
},
client => sub {
my $port = shift;
diag "$$: cl $port";
my $cl = Echo::Client->new(
host => '127.0.0.1',
port => $port,
reconnect => 0.1,
debug => 0,
);
my $action = 0;
$cl->reg_cb(
( run in 0.573 second using v1.01-cache-2.11-cpan-39bf76dae61 )