Socket error: 10053 software caused connection abort

David M. Cooke cookedm+news at physics.mcmaster.ca
Thu Apr 15 17:38:28 EDT 2004


At some point, "Jean-Pierre Bergamin" <james at ractive.ch> wrote:

> Hi Irmen
>
>> But this code is flawed: recv() CAN return less than block_size,
>> *even* if there is more data to be read on the socket.
>>
>> So, you should not check if the length of the received chunk
>> is less than the length argument passed to recv().
>>
>> Instead, you should count the total number of bytes you
>> received and check that with the expected total amount.
>
> But how can I know the amout of data I will receive? There's no way to do
> that, since it's totally random how large the sent data will be.

You don't know, unless you send the size (like HTTP with the
Content-length: header), or have some way of knowing when
you're done (like SMTP or IMAP, which use CR-LF to signify the end of
the line).

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list