为什么"htons"和"ntohs"都存在? [英] Why do both `htons` and `ntohs` exist?

查看:86
本文介绍了为什么"htons"和"ntohs"都存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定标准库中为什么同时存在 htons 和 ntohs .他们做的完全一样-除非我不知何故感到困惑!

I am not sure why htons and ntohs both exist in the standard library. They do exactly the same thing -- unless I'm confused somehow!

htonl ntohl 也是如此.

推荐答案

它们用于编写自我记录的代码,该代码告诉读者数据是按主机顺序还是按网络顺序排列.

They make for self-documenting code that tells the reader whether the data is in host- or network- order.

这篇关于为什么"htons"和"ntohs"都存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆