help on packet format for tcp/ip programming
Grant Edwards
grante at visi.com
Thu Feb 8 11:58:39 EST 2007
On 2007-02-08, Diez B. Roggisch <deets at nospam.web.de> wrote:
>>>> struct module pack and unpack will only work for fixed size buffer :
>>>> pack('>1024sIL', buffer, count. offset) but the buffer size can vary
>>>> from one packet to the next :-(
>>>
>>> Oh for Pete's sake...
>>>
>>> struct.pack('>%dsIL' % len(buffer), buffer, count, offset)
>>
>>
>> that is great but how does one unpack on the other side?
>
> By peeking into the header, determining the number of bytes necessary?
Better yet, use a protocol that's not brain-dead: send the
buffer size _before_ you send the buffer.
> But why do you need this anyway - if you know that you will
> have python on both ends, use Pyro or xmlrpc.
--
Grant Edwards grante Yow! A dwarf is passing
at out somewhere in Detroit!
visi.com
More information about the Python-list
mailing list