ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/handle/04_listen.t
(Generate patch)

Comparing AnyEvent/t/handle/04_listen.t (file contents):
Revision 1.1 by elmex, Sun Apr 27 16:56:18 2008 UTC vs.
Revision 1.5 by root, Fri May 2 09:07:02 2008 UTC

1#!/opt/perl/bin/perl 1#!/opt/perl/bin/perl
2
2use strict; 3use strict;
3use Test::More tests => 2; 4use Test::More tests => 2;
5use AnyEvent::Impl::Perl;
4use AnyEvent; 6use AnyEvent;
5use AnyEvent::Socket; 7use AnyEvent::Socket;
6 8
7my $lbytes; 9my $lbytes;
8my $rbytes; 10my $rbytes;
13 AnyEvent::Socket->new ( 15 AnyEvent::Socket->new (
14 Listen => 1, 16 Listen => 1,
15 LocalPort => 32391, 17 LocalPort => 32391,
16 ReuseAddr => 1, 18 ReuseAddr => 1,
17 ); 19 );
20
18my $ae_sock = 21my $ae_sock =
19 AnyEvent::Socket->new ( 22 AnyEvent::Socket->new (
20 PeerAddr => "localhost:32391", 23 PeerAddr => "127.0.0.1:32391",
21 on_connect => sub { 24 on_connect => sub {
22 my ($ae_sock, $error) = @_; 25 my ($ae_sock, $error) = @_;
23 if ($error) { diag "connection failed: $!"; $cv->broadcast; return } 26 if ($error) { diag "connection failed: $!"; $cv->broadcast; return }
24 27
25 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";
52 55
53$cv->wait; 56$cv->wait;
54 57
55is ($lbytes, "TEST\015\012", 'listening end received data'); 58is ($lbytes, "TEST\015\012", 'listening end received data');
56is ($rbytes, "BLABLABLA\015\012", 'connecting received response'); 59is ($rbytes, "BLABLABLA\015\012", 'connecting received response');
60

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines