Differences between version 2 and predecessor to the previous major change of NetworkByteOrder.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 2 | Last edited on Saturday, March 19, 2005 11:39:23 am | by AristotlePagaltzis | Revert |
Older page: | version 1 | Last edited on Sunday, July 28, 2002 11:29:40 am | by WikiAdmin | Revert |
@@ -1 +1,3 @@
-The [Endian
] of bytes when
sent over the wire in
a protocol
.
Most NetworkByteOrder'
s are BigEndian, however notably microsoft protocols
tend to be LittleEndian. Intel Machines are LittleEndian. LibC
provides functions to convert to/from NetworkByteOrder (BigEndian) from HostByteOrder (on Intel LittleEndian)
called htonl(3) (host to network long (32 bits)), htons(3) (host to network short (16 bits)), ntohl(3) (network to host long (32bits)), ntohs(3) (network to host short (16bits)).
+The [Endianness
] that should be assumed for data
sent over a network
. Most NetworkByteOrder~
s, notably including that of [TCP/IP],
are BigEndian. Protocols designed at MicrosoftCorporation, being [x86]-centric as it is
, tend to be LittleEndian.
+
+Libc
provides functions called htonl(3) (host to network long (32 bits)), htons(3) (host to network short (16 bits)), ntohl(3) (network to host long (32bits)), and
ntohs(3) (network to host short (16bits)) to convert between host byte order and NetworkByteOrder. By using these functions, the code will Do The Right Thing regardless of whether it is being compiled for a big- or little-endian machine
.