Sockets: Sending/receiving arbitrary amounts of data

Daniel Klein danielk at aracnet.com
Mon Apr 30 09:56:34 EDT 2001


On Sun, 29 Apr 2001 10:54:17 -0700, Neil Schemenauer <nas at python.ca> wrote:

>Daniel Klein wrote:
>> What if the server doesn't know in advance how much data will
>> be sent from the client?
>
>You need to build this into your protocol.  A lot of existing
>protocols use terminators to signal the end of data like "\r\n"
>or something similar.  I like using Dan Bernstein's netstring
>protocol:

Thanks Neil, this is exactly what I was proposing to do.

Question: Why is the protocol using 'u' instead of 'i' in the format string?

	"%lu:" % len(s)
vs
	"%li:" % len(s)

Thanks for the code,

Dan




More information about the Python-list mailing list