OverflowError while sending large file via socket

Jean-Paul Calderone exarkun at divmod.com
Sun Apr 12 21:55:26 EDT 2009


On 13 Apr 2009 01:45:56 GMT, Steven D'Aprano <steve at remove-this-cybersource.com.au> wrote:
>On Mon, 13 Apr 2009 00:21:34 +0200, Ryniek90 wrote:
>
>> When i wanted to send an .iso file of 4GB length, i had traceback:
>> "OverflowError: requested number of bytes is more than a Python string
>> can hold"
>>
>> Sockets are being used in every network app, i.e: p2p progs (like
>> BitTorrent), and exchanged data is often bigger than 4GB.
>
>But they don't transfer the entire file as ONE packet. Split your data
>into smaller packets. I don't know what a good size for each packet would
>be, but if I were doing this, I'd probably start with 4096 or 8192
>*bytes*.

Everything in that paragraph is true, but it's rather misleading.  The
size of the packets you send is *not* determined by the length of the
string you pass to socket.send.  Packet size in a TCP connection is
determined by various things beyond the control of an application using
the BSD socket API.

Jean-Paul



More information about the Python-list mailing list