0

I know how endians work. I read somewhere a statement "the internet, for instance, agrees on everything being big endians". How does that work? If I have a tcp connection between 2 machines, how do these machines decide what endian to use?

1

The decision of endianness is not made at connection time, it is a property of the format or protocol in use. In your example, all of the machines know that the protocol specifies a big-endian format, so that is how data is sent and interpreted.

  • what protocol is this? – luke kong Mar 26 at 23:35
  • In your example, the Transmission Control Protocol (tcp), but this applies in general to almost anything – Fox Mar 27 at 0:51
  • 1
    Just in case, use htonl()/ntohl() functions to convert byte order. man(3) htonl – Mikhail Zakharov Mar 29 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.