[erlang-questions] Writing platform independent Socket based binary parsing code

Richard O'Keefe <>
Sun May 13 23:49:09 CEST 2012


If the data are big-endian on the wire, use /big.
If the data are little-endian on the wire, use /little.
Use the *same* Erlang code to match the wire data
whether you are using a big-endian SPARC or a little-
endian x86-64.

> I am aware of the fact that from network we get data in our application in Big Endian format and in c/c++ I would use ntohs/ntohl functions for converting it into a format that the OS supports.
> But, the same in Erlang is confusing me (no idea why !!).

In effect, binary matching *is* ntoh... and binary
construction *is* hton...





More information about the erlang-questions mailing list