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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With