赫顿斯数据传输中的 ntohl
我一直想知道,为什么在使用写/读时不必使用htons/ntohl? (至少到目前为止我看到的所有示例都没有。)
我如何知道接收到的字节具有正确的字节顺序?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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.