1 | #!/opt/perl/bin/perl |
1 | #!/opt/perl/bin/perl |
|
|
2 | |
2 | use strict; |
3 | use strict; |
3 | use Test::More tests => 2; |
4 | use Test::More tests => 2; |
|
|
5 | use AnyEvent::Impl::Perl; |
4 | use AnyEvent; |
6 | use AnyEvent; |
5 | use AnyEvent::Socket; |
7 | use AnyEvent::Socket; |
6 | |
8 | |
7 | my $lbytes; |
9 | my $lbytes; |
8 | my $rbytes; |
10 | my $rbytes; |
… | |
… | |
15 | LocalPort => 32391, |
17 | LocalPort => 32391, |
16 | ReuseAddr => 1, |
18 | ReuseAddr => 1, |
17 | ); |
19 | ); |
18 | my $ae_sock = |
20 | my $ae_sock = |
19 | AnyEvent::Socket->new ( |
21 | AnyEvent::Socket->new ( |
20 | PeerAddr => "localhost:32391", |
22 | PeerAddr => "127.0.0.1:32391", |
21 | on_connect => sub { |
23 | on_connect => sub { |
22 | my ($ae_sock, $error) = @_; |
24 | my ($ae_sock, $error) = @_; |
23 | if ($error) { diag "connection failed: $!"; $cv->broadcast; return } |
25 | if ($error) { diag "connection failed: $!"; $cv->broadcast; return } |
24 | |
26 | |
25 | print "connected to ".$ae_sock->fh->peerhost.":".$ae_sock->fh->peerport."\n"; |
27 | print "connected to ".$ae_sock->fh->peerhost.":".$ae_sock->fh->peerport."\n"; |