1
votes

I'm writing an implementation of the AMF (Action Message Format) protocol in JS. Do I need to take endianness into account when parsing a byte stream from the network? The reason I ask is because, AFAIK, most systems these days are little-endian, but apparently all data coming over TCP/IP is in big-endian (network byte order).

1
As if it weren't painfully obviously already, I'm a bit of a n00b when it comes to binary processing and I haven't had a full formal CS education. Be gentle :) - Danny Kopping
All good, but I am pretty sure the TCP stack would take care of this for you.. Is there a specific issue this is causing? Can you post code/more information about a problem or are you just searching for more info? - Michael Coxon
No specific issue - just trying to be prudent :) - Danny Kopping
No probs. Yeah well as I said I think the TCP stack should take care of this. But it will be different depending on the device. x86 is little endian, where as I am pretty sure ARM is big-endian. Hopefully someone can shed a little more light on this more you. - Michael Coxon

1 Answers

0
votes

If you're transferring bytes, they're seen as bytes. The endianness is determined by the data source's implementation, so it could be either big or little endian.

Regardless, the accepted norm for TCP/IP transfers is big endian and most transfers follow this rule.

I would suggest that the easiest way to determine the endianness of your source data is to go ahead and try to parse it and compare your result with a sample.