/usr/share/doc/libanyevent-perl/examples/ae2.pl is in libanyevent-perl 7.070-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # $Id: ae2.pl,v 1.2 2009-08-06 14:00:36 root Exp $
# An echo client-server benchmark.
use warnings;
use strict;
use Time::HiRes qw(time);
use AnyEvent;
use AnyEvent::Impl::Perl;
use AnyEvent::Socket;
my $CYCLES = 500;
my $port = 11212;
tcp_server undef, $port, sub {
my ($fh) = @_
or die "tcp_server: $!";
my $hdl = new AnyEvent::Handle fh => $fh;
$hdl->push_read (line => sub {
$hdl->push_write ("$_[1]\n");
undef $hdl;
});
};
my $t = time;
for my $connections (1..$CYCLES) {
my $cv = AE::cv;
tcp_connect "127.0.0.1", $port, sub {
my ($fh) = @_
or die "tcp_connect: $!";
my $hdl = new AnyEvent::Handle fh => $fh;
$hdl->push_write ("can write $connections\n");
$hdl->push_read (line => sub {
undef $hdl;
$cv->send;
});
};
$cv->recv;
};
$t = time - $t;
printf "%.3f sec\n", $t;
exit;
|