赫顿斯数据传输中的 ntohl

发布于 2024-12-15 13:05:40 字数 92 浏览 4 评论 0原文

我一直想知道,为什么在使用写/读时不必使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

许仙没带伞 2024-12-22 13:05:40

好吧,如果您希望在不同字节顺序的系统之间交换文件,您必须这样做 - 只是与网络协议相比,该问题在文件上下文中出现的情况更罕见因此常常被忽视。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文