网络上的大端或小端?

编程入门 行业动态 更新时间:2024-10-28 17:22:30
本文介绍了网络上的大端或小端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

网络上以什么字节顺序进行数据传输?是Little Endian还是Big Endian?数据到达主机后如何将其转换为相应的字节顺序?

In what byte order does data transfer occur on net? Is it Little Endian or big endian? How is it converted to the respective byte order once the data reaches the host ?

推荐答案

网络字节顺序"为Big Endian,TCP等协议将其用于整数字段(例如端口号).可以使用htons和ntohs之类的功能进行转换.

"Network byte order" is Big Endian, and protocols such as TCP use this for integer fields (e.g. port numbers). Functions such as htons and ntohs can be used to do conversion.

除非您使用的是演示层,否则数据本身不具有完全由应用程序定义的字节序(例如XDR).

The data itself doesn't have any endianness it's entirely application defined, unless you're using a Presentation Layer such as XDR.

更多推荐

网络上的大端或小端?

本文发布于:2023-07-29 19:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1243486.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大端   网络

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!