Network byte ordering question ...

David Bolen db3l at fitlinxx.com
Mon Jun 5 23:51:37 EDT 2000


David Bolen <db3l at fitlinxx.com> writes:

> As you indicated you had looked at, you could probably use the struct
> module, and that may be the simplest approach.  One caution is that
> the module doesn't really guarantee much about the alignment of
> individual elements in a structure, so I would suggest slicing off the
> fields you need to decode and then unpacking them individually.

Following up on my own post, but after seeing the other response by
Mike Fletcher I went back and double checked the module and I was
mistaken - it does in fact offer standardized alignment, so the above
is incorrect if you explicitly set the byte order / alignment (such as
with the "!"  character).  So unpacking in full should be fine as long
as you specify the byte ordering.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list