ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/Deliantra/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra/Deliantra/Protocol.pm (file contents):
Revision 1.7 by root, Fri Apr 7 23:16:17 2006 UTC vs.
Revision 1.8 by root, Sat Apr 8 13:33:29 2006 UTC

37 37
38 my $buf; 38 my $buf;
39 39
40 $self->{w} = AnyEvent->io (fh => $self->{fh}, poll => 'r', cb => sub { 40 $self->{w} = AnyEvent->io (fh => $self->{fh}, poll => 'r', cb => sub {
41 if (sysread $self->{fh}, $buf, 16384, length $buf) { 41 if (sysread $self->{fh}, $buf, 16384, length $buf) {
42 if (2 <= length $buf) { 42 for (;;) {
43 last unless 2 <= length $buf;
43 my $len = unpack "n", $buf; 44 my $len = unpack "n", $buf;
44 if ($len + 2 <= length $buf) { 45 last unless $len + 2 <= length $buf;
46
45 substr $buf, 0, 2, ""; 47 substr $buf, 0, 2, "";
46 $self->feed (substr $buf, 0, $len, ""); 48 $self->feed (substr $buf, 0, $len, "");
47 }
48 } 49 }
49 } else { 50 } else {
50 delete $self->{w}; 51 delete $self->{w};
51 close $self->{fh}; 52 close $self->{fh};
52 } 53 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines