Socket Question
Panu A Kalliokoski
pkalliok at cc.helsinki.fi
Thu May 31 08:49:48 EDT 2001
Daniel Klein <danielk at aracnet.com> wrote:
>>If you're using TCP, the size of the chunks you read may vary.
>>You have to deal with the data stream being delivered in
>>whatever size chunks please the intervening software and
>>hardware (regardless of what size chunks with which it was
>>written).
> That's what I thought. Thanks.
The number of bytes you get from the OS at a time depends on
the implementation of the TCP/IP stack and on how much bytes
there are available. The "normal" solution is to ask for
(bytes_wanted - bytes_got) bytes until you get the number of
bytes you want. Or if you're dealing with a chat-type protocol
with record separators, you should of course ask for more data
until you see the separator (a newline for example).
Panu
More information about the Python-list
mailing list