5

I have always wondered, why don't I have to use htons/ntohl when using write/read? (At least all examples I have seen so far don't.)

How do I know that the bytes received have the correct endianness?

gaddomn
  • 125
  • 2
  • 4

1 Answers1

1

Well, you have to, if you ever intend your files to be exchanged between systems of a different endianness - it is just that the problem tends to come up more rarely in the context of files than with network protocols and so is often ignored.

themel
  • 8,825
  • 2
  • 32
  • 31