Network byte ordering question ...

Mike Fletcher mfletch at tpresence.com
Wed Jun 7 03:17:15 EDT 2000


Strange, I was under the impression that network byte ordering was '>', with
'<' being a little-endian (non-network) encoding.  You sure your headers are
really network ordered?

>>> import struct
>>> struct.pack( '>i', 1 )
'\000\000\000\001'
>>> # note the big-endian (network) encoding

Don't know if there are any _current_ Waterloovian Pythonistas, the two I
knew about (Paul and myself) having both graduated a while ago... and not
even an alumni newsletter to show for it in my case ;) .  Enjoy,
Mike

-----Original Message-----
From: istevens at calum.csclub.uwaterloo.ca
[mailto:istevens at calum.csclub.uwaterloo.ca]
Sent: Tuesday, June 06, 2000 8:08 PM
To: python-list at python.org
Subject: Re: Network byte ordering question ...


In article <CC59868A0A76D311B1F50090277B321C1F3394 at VRTMAIL>,
Mike Fletcher  <mfletch at tpresence.com> wrote:

>( val1, val2, val3, val4, val5 ) = unpack( ">16sBBBi", header )

Thanks!  Actually, the following works better:

    ( val1, val2, val3, val4, val5 ) = unpack( "<16sBBBI", header )

I tried this both on an Intel and a Sun machine and they both return
what I expect.  I also forgot to mention that the last value was
unsigned.

>Yay! another Waterloovian Pythonista!

Actually, ex-Waterloo ... graduated last year.


thanks again,
ian.
-- 
http://www.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list