On 25/10/2011 16:00, Gary wrote:
I wrote:
After sending a request to a server [...]
I get some part of the data back that I requested, and then only some
time later, after my code thinks it's got everything, has continued and
is trying to receive returned data from a subsequent request, does it
get the missing part of the first set of data.
For the record, this is what I did to get around the problem:
,----[ code ]
| my $s = IO::Select->new($self->{_sock});
| while (my @ready = $s->can_read(1)) {
| my $recd = RECV_BUF_SIZE;
|
| while ($recd == RECV_BUF_SIZE) {
| my $buf = '';
|
| $self->{_sock}->recv($buf, RECV_BUF_SIZE, MSG_WAITALL);
|
| $recd = length($buf);
| $ret .= $buf;
| }
| }
`----
Note the added 'while' loop around the recv loop.
I can only say "it seems to work". I'm not really au fait enough with
this to say that it's a solution.
This seems unecessarily tedious and low-level.
I think you may get some mileage from the pproach described in
perldoc perlipc
where reading from and writing to a socket is reduced to
while (<$self->{_sock}>) {
...
}
and
print $self->{_sock} "Data\n";
I would have said something earlier but I am far from familiar with
sockets programming and I thought someone else would be better qualified
to answer your question.
Cheers,
Rob
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/