Unpacking binary data with struct.unpack

David Bolen db3l at fitlinxx.com
Mon Aug 7 16:02:13 EDT 2000


"Alex Martelli" <alex at magenta.com> writes:

> "Holger Fuessler" <holger at fuessler-net.de> wrote in message
> news:8iulm8.n22.ln at odin.hmf.de...
> > it works now. The problem is now that I don't know how the value is
> encoded.
> > Is there general encoding scheme for number transported over tcp-ip?
> 
> Assuming you're talking about an integer number, then both
> big-endian (high byte first) and little-endian (low byte first)
> orders are used.  (...)

Sort of - TCP and IP by definition only use network ordering
(big-endian) for all protocol values.

In terms of the payload that the protocols transport, they only treat
them as a raw octet stream, so there's no concept of multi-octet
ordering at all aside from the overall sequence of the stream of data.

As far as values embedded within the payload (which neither TCP nor IP
understand nor care about), then as you say any order can be used -
it's up to the applications creating and processing the data.

--
-- 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