logoalt Hacker News

j16sdiztoday at 3:30 PM4 repliesview on HN

If you comes to low level network protocol (e.g. writing a TCP stack), the "network byte order" is always big-endian.


Replies

edflsafoiewqtoday at 4:59 PM

That's a serialization format.

7jjjjjjjtoday at 5:08 PM

It goes without saying that all binary network protocols should document their byte order, and that if you're implementing a protocol documented as big endian you should use ntohl and friends to ensure correctness.

However if designing a new network protocol, choosing big endian is insanity. Use little endian, skip the macros, and just add

  #ifndef LITTLE_ENDIAN
    #error
Or the like to a header somewhere.
show 1 reply
whizztertoday at 5:22 PM

And honestly at this point it's mostly a historical artifact, if we write that kind of stuff then sure we need to care but to produce modern stuff is a honestly massive waste of time at this point.

FWIW I doing hobby-stuff for Amiga's (68k big-endian) but that's just that, hobby stuff.

skrtskrttoday at 3:43 PM

Prometheus index format is also a big-endian binary file - haven’t found any reference to why it was chosen.