How to receive a data file of unknown length using a python socket?

Aahz aahz at pythoncraft.com
Sat Jul 18 22:46:01 EDT 2009


In article <mailman.3382.1247958334.8015.python-list at python.org>,
MRAB  <python at mrabarnett.plus.com> wrote:
>
>If you send the length as 4 bytes then you'll have to decide whether
>it's big-endian or little-endian. An alternative is to send the length
>as characters, terminated by, say, '\n' or chr(0).

Alternatively, make it a fixed-length string of bytes, zero-padded in
front.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"The volume of a pizza of thickness 'a' and radius 'z' is
given by pi*z*z*a"



More information about the Python-list mailing list