note
bibo
Another way to do it...
<p>Here's some client code for a slower responding socket server, or when all the data doesn't show up at once, due to other issues. It sends a chunk, and waits for a response, up to N loops. Small sleeps might be safer than just looping, but hey, everyone works differently. You also could add checks for some termination sequence, or checks for the chunk meeting a fixed size requirement.<p>
--bibo
<code>
my $indata;
my $remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr =>'127.0.0.1' ,
PeerPort => $self->{'30000'},
);
if( defined($remote) ) {
my $readsize;
print $remote $bigdata;
my $done = 0;
my $zreads =0;
while (! $done) {
my $tempdata="";
$tempdata = <$remote>;
$readsize = length $tempdata;
$zreads++ if ($readsize == 0);
$done = 1 if ($zreads > 30);
$in_data = $in_data . $tempdata;
$done = 1 if ($tempdata eq "\n");
}
close $remote;
}
</code>
395564
395564