网络字节顺序对于专有协议重要吗?
所以我有一个通过 UDP 运行的自定义二进制协议。
我的源是一个小端嵌入式设备,传输基本上是 send(packed struct) 。我的目标设备绝大多数都是小端 PC。
我收到更改网络字节顺序的请求。我的第一反应是“没有机会”。我不认为翻转我的 100 多个字段中的每一个字段(2 到 8 字节整数以及浮点数和双精度数的混合),然后让我的大多数用户右转并将它们全部翻转回去有任何意义,并处理双方所有的小编码错误。
我错过了什么吗?如今网络字节顺序真的很重要吗?这真的重要吗?指定字节顺序显然至关重要,但除此之外,谁真正关心呢?
So I've got a custom binary protocol that runs over UDP.
My source is a little-endian embedded device, with the transmit basically being send(packed struct) . My destination devices are overwhelmingly going to be little endian PCs.
I got a request to change to network byte order. My instant response was "not a chance". I'm not seeing any point in going and flipping every one of my 100+ fields, a mix of 2 to 8 byte integers, along with floats and doubles, and then making most all of my users turn right around and flip them all back, and dealing with all the minor coding errors on both sides.
Am I missing something? Does network byte order really matter today? Did it really ever matter? Specifying what the byte order is obviously critically important, but beyond that, who really cares?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无论网络上的其他机器使用什么,都无需切换到网络字节顺序 - 您可以完全自由地声明 XPav 协议使用小端值。
当然,当它成为国际标准时,这可能会有点问题——但那是未来的事了。
There is no need to switch to network byte order whatever the other machines on the network use - you are perfectly free to declare that the XPav protocol uses little-endian values.
Of course when it becomes an international standard that might be a bit of a problem - but that's in the future.