Network byte order is big-endian, the most significant byte first, and it's the standard order for multi-byte binary values transmitted on the network (it's defined by the protocols, e.g., the port and length fields in TCP/IP headers). It matters because host machines may store integers in a different order: little-endian (like most ARM and x86) stores the least significant byte first, so if you put a 16-bit port or a 32-bit integer directly onto the wire without converting, the bytes come out swapped and the peer interprets them wrong, a port of 8080 becomes some unrelated value, or a length field is wildly off. The fix is to convert at the boundary: htons/htonl (host-to-network, 16/32-bit) when placing values into packet structures or socket addresses, and ntohs/ntohl (network-to-host) when reading them out. On a big-endian host these macros are no-ops, which is exactly why code that "worked" on one machine breaks on another, so you always call them rather than relying on the host's endianness. This is the endianness issue from low-level C, applied specifically to anything that crosses the network.
Networking & IoT · Interview question
What is network byte order and why does it matter?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Sockets
The programming interface to TCP/UDP: the BSD socket calls (socket/connect/send/recv, bind/listen/accept), client and server flows, byte order, and the partial-I/O and blocking traps on an MCU.