Byte Order

Big-Endian
When storing a two-byte hex number, say "b34f", they should be stored in two sequential bytes "b3" followed by "4f".This number is stored with the big end first, and is called Big-Endian.

This Big-Endian method is also known as "Network Byte Order"

If the computer is a Motorola 68k, Host Byte Order is Big-Endian.

Little-Endian
If were using the oposite method, Little-Endian, "b34f" would be stored by two sequential bytes "4f" followed by "b3".

If the computer is an Intel 80x86, Host Byte Order is Little-Endian.

Network Byte Order vs Host Byte Order
Network Byte Order is the way that bytes should be ordered when they are on the network, and Host Byte Order is the way they should be ordered when in the host. As NBO and HBO differs, convertion between network and host needs to be done. A lot of times when building packets or filling out data structures, two- and four-byte numbers needs to be in Network Byte Order. As the native host byte order isn't known, this could be a problem. To ensure this, the value should always be ran through a function that sets it to Network Byte Order. This function will "magically" convert the value if needed.

Ways to convert

 * htons - host to network short
 * htonl - host to network long
 * ntohs - network to host short
 * ntohl - network to host long