socket question
hg
hg at nospam.com
Wed Sep 13 09:50:37 EDT 2006
Jean-Paul Calderone wrote:
> On Wed, 13 Sep 2006 08:13:43 -0500, hg <hg at nospam.com> wrote:
>> Hi,
>>
>> I am not sure whether this is a python-related question.
>>
>> If I have device A than sends XX bytes to device B, and device B does a
>> recv(XX) using the default timeout, what could make device B wake-up
>> with less than XX bytes received ?
>
> Assuming the sends take place over a TCP connection, any number of things.
> In generally, you cannot rely on anything about the length of the string
> returned from recv(N) except that:
>
> it will not be greater than N
> it will not be less than 1 unless the connection has been lost
>
> If you expect a particular number of bytes, you need to call recv()
> multiple times and collect the returned strings until you have as many
> bytes as you wanted.
>
> Jean-Paul
Many thanks,
hg
More information about the Python-list
mailing list