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.15 by root, Sun May 25 02:26:49 2008 UTC vs.
Revision 1.16 by root, Fri Jul 24 22:47:04 2009 UTC

38 $port = $_[2]; 38 $port = $_[2];
39 39
40 0 40 0
41 }; 41 };
42 42
43my $clhdl; 43my $clhdl; $clhdl = AnyEvent::Handle->new (
44my $wc = tcp_connect localhost => $port, sub { 44 connect => [localhost => $port],
45 my ($fh) = @_ 45 on_eof => sub { $cv->broadcast },
46 or die "connect: $!"; 46);
47 47
48 $clhdl = AnyEvent::Handle->new (fh => $fh, on_eof => sub { $cv->broadcast }); 48$clhdl->push_write ("TEST\015\012");
49$clhdl->push_read (line => sub {
50 my ($clhdl, $line) = @_;
49 51
50 $clhdl->push_write ("TEST\015\012"); 52 if ($line eq 'BLABLABLA') {
51 $clhdl->push_read (line => sub { 53 print "ok 2 - client received response\n";
52 my ($clhdl, $line) = @_; 54 } else {
55 print "not ok 2 - client received bad response\n";
56 }
53 57
54 if ($line eq 'BLABLABLA') {
55 print "ok 2 - client received response\n";
56 } else {
57 print "not ok 2 - client received bad response\n";
58 }
59
60 $cv->broadcast; 58 $cv->broadcast;
61 });
62}; 59});
63 60
64$cv->wait; 61$cv->wait;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines