Network byte ordering question ...
Mike Fletcher
mfletch at tpresence.com
Mon Jun 5 23:05:56 EDT 2000
More information about the Python-list mailing list
Mon Jun 5 23:05:56 EDT 2000
- Previous message (by thread): Network byte ordering question ...
- Next message (by thread): Network byte ordering question ...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
( val1, val2, val3, val4, val5 ) = unpack( ">16sBBBi", header ) Should do it, no? That is, the header is a string of 16 bytes followed by 3 unsigned single-byte integers, followed by a (signed) 32bit integer, all in Network Byte Order. You pack/unpack from/to Python native values, which are always in the machine's byte order. Packing would use the same pattern, and takes care of translating to/from network byte order. Yay! another Waterloovian Pythonista! Mike -----Original Message----- From: istevens at calum.csclub.uwaterloo.ca [mailto:istevens at calum.csclub.uwaterloo.ca] Sent: Monday, June 05, 2000 9:22 PM To: python-list at python.org Subject: Network byte ordering question ... ... FYI, here's what I've tried: ( val1, val2, val3, val4, val5 ) = unpack( "@16s1s1s1s4s", header ) This works somewhat but I would really like val1 to read as a string containing numeric values (to preserve leading zeroes) and the other values to read as numbers. This is also specific to little-endian machines and I'd like to generalize it. ...
- Previous message (by thread): Network byte ordering question ...
- Next message (by thread): Network byte ordering question ...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list