Ahem, I took another look at the game, just ignore my previous rambling.
Discovered the following though:
This pattern can never match since the line is chomped?} elsif ($get =~ /MESSAGE ([^ ]+) (.*)\n$/) {
Why is Tk::repeat necessary, what happens if it's omitted?
Update: ah, I see it now. Why don't you modify get_line to return all lines available if wantarray?
Process could then do ... for my $get (get_line($server)) {} ...
Update. TCP.pm in the git, does it not read as follows:
sub get_line { my ($fh) = @_; warn "Getting from $fh\n"; my $line = read_from_buffer($fh); return $line if defined $line; if (sysread $fh, my $read, BUFF_SIZE) { warn "sysread $read"; $buff{$fh} .= $read; } $line = read_from_buffer($fh); warn "Got $line\n"; warn do { use Data::Dumper; Dumper $buff{$fh} }; return $line; }
I would simply write (untested):
sub get_line { my ($fh) = @_; warn "Getting from $fh\n"; my $line = read_from_buffer($fh); return $line if defined $line; sysread($fh, $_, BUFF_SIZE, length) for $buff{$fh}; return get_line($fh); }
In reply to Re: A Game Using TCP Sockets
by oiskuu
in thread A Game Using TCP Sockets
by choroba
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |