… | |
… | |
15 | AnyEvent::Socket->new ( |
15 | AnyEvent::Socket->new ( |
16 | Listen => 1, |
16 | Listen => 1, |
17 | LocalPort => 32391, |
17 | LocalPort => 32391, |
18 | ReuseAddr => 1, |
18 | ReuseAddr => 1, |
19 | ); |
19 | ); |
|
|
20 | |
20 | my $ae_sock = |
21 | my $ae_sock = |
21 | AnyEvent::Socket->new ( |
22 | AnyEvent::Socket->new ( |
22 | PeerAddr => "localhost:32391", |
23 | PeerAddr => "127.0.0.1:32391", |
23 | on_connect => sub { |
24 | on_connect => sub { |
24 | my ($ae_sock, $error) = @_; |
25 | my ($ae_sock, $error) = @_; |
25 | if ($error) { diag "connection failed: $!"; $cv->broadcast; return } |
26 | if ($error) { diag "connection failed: $!"; $cv->broadcast; return } |
26 | |
27 | |
27 | print "connected to ".$ae_sock->fh->peerhost.":".$ae_sock->fh->peerport."\n"; |
28 | print "connected to ".$ae_sock->fh->peerhost.":".$ae_sock->fh->peerport."\n"; |