data serialization and transport using python:protocol question
- From: "Tyler Littlefield" <tyler@xxxxxxxxxxxxx>
- To: <programmingblind@xxxxxxxxxxxxx>
- Date: Sun, 24 May 2009 02:25:45 -0600
Hello list,
I've got a quick question.
I was looking at using the struct module to serialize some data for
transportation through a socket or a pipe, and was trying to figure out the
most efficient way of setting this up.
I'd like the max length of a message to be 4096, which is 4 kb in size.
Now, when I set this up, I can pad with zeros, but that means that for every
message, whether it's 3 chars long or 500 chars long, I still have all that
extra overhead.
Is there an easier way to do this that wouldn't be so bandwidth consuming?
4 kb may not be much, but it'll get rough if there are multiple people
connecting to the same server.
I'd thought about keeping the length of the data and adding that to the top
of the struct, then decompressing using that, but I'd have to unpack the
structure twice, unless there is a way I can just read the int off the top,
and do something like:
">dd"+str(length)+"s" etc...
Thanks,
Tyler Littlefield
Web: tysdomain.com
email: tyler@xxxxxxxxxxxxx
My programs don't have bugs, they're called randomly added features.
__________
View the list's information and change your settings at
http://www.freelists.org/list/programmingblind
Other related posts: