Socket error: 10053 software caused connection abort

Jean-Pierre Bergamin james at ractive.ch
Thu Apr 15 15:12:15 EDT 2004


Hi Irmen

>> I'm getting an error on Windows XP when I send big data chunks over
>> a socket connection. The exception I get is: "socket.error: (10053,
>> 'Software caused connection abort')"
>> This happens in the socket.recv function.
>
> I have the same error here, and it is NOT because of a bug in
> Windows' TCP stack. (even though the problem does not occur on Linux).
>
> The problem is in your code.
>
> You are receiving chunks of data like this:

> [....]

> 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.

Could you show me how you did it?


Thanks

James





More information about the Python-list mailing list