Big endian or Little endian on net?

TwiggedToday picture TwiggedToday · Jun 15, 2009 · Viewed 20.4k times · Source

In what byte order does data transfer occur on net? Is it Little Endian or big endian? How is it converted to the respective byte order once the data reaches the host ?

Answer

brian-brazil picture brian-brazil · Jun 15, 2009

"Network byte order" is Big Endian, and protocols such as TCP use this for integer fields (e.g. port numbers). Functions such as htons and ntohs can be used to do conversion.

The data itself doesn't have any endianness it's entirely application defined, unless you're using a Presentation Layer such as XDR.