help on packet format for tcp/ip programming

Grant Edwards grante at visi.com
Thu Feb 8 11:57:07 EST 2007


On 2007-02-08, rattan at cps.cmich.edu <rattan at cps.cmich.edu> wrote:
> On Feb 8, 3:40 am, Grant Edwards <gra... at visi.com> wrote:
>> On 2007-02-08, rat... at cps.cmich.edu <rat... at cps.cmich.edu> 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?

struct.unpack('>%dsIL' % buflen ,packet)

-- 
Grant Edwards                   grante             Yow!  Yow! Did something
                                  at               bad happen or am I in a
                               visi.com            drive-in movie??



More information about the Python-list mailing list