help on packet format for tcp/ip programming

Grant Edwards grante at visi.com
Wed Feb 7 22:40:46 EST 2007


On 2007-02-08, rattan at cps.cmich.edu <rattan 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)

-- 
Grant Edwards                   grante             Yow!  I want the presidency
                                  at               so bad I can already taste
                               visi.com            the hors d'oeuvres.



More information about the Python-list mailing list