Network byte order

wim sturkenboom

Well-known member
Aug 6, 2014
Roodepoort, South Africa
Programming Experience
Not sure where to post this; if in the wrong section, please move.

I'm writing a server that receives data from a client. The client spec states that integers are transmitted in "network byte order".

The first 4 bytes in my received data represent an (unsigned) 32 bit integer and are show below. Question is what the decimal representation of the received integer is assuming it is in network byte order?

 02 00 00 00

The value is supposed to be '2', but that does not match the "network byte order"; unless I got it totally wrong. Thanks in advance for reading and advise.
That is referring to endianness of the bytes. .Net byte order is "host order" little-endian (Intel standard), "network order" is big-endian.
For example integer 2 little-endian is {2,0,0,0} and big-endian (network) is {0,0,0,2}.
You have classes like BitConverter that has conversion for values to/from bytes (and field IsLittleEndian that return host order), IPAddress class that has HostToNetworkOrder/NetworkToHostOrder methods for some data types.
Thanks for the reply and the confirmation that the value that I receive does not represent '2' decimal.

Guess I found a bug in the product or product documentation that generates the data :(

I'm aware of the classes and I'm using them. Did not know about 'IsLittleEndian'.
This is running on Intel hardware, so the host order is littleEndian.
Top Bottom