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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.