网络上的大端或小端? [英] Big endian or Little endian on net?

查看:97
本文介绍了网络上的大端或小端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网络上以什么字节顺序进行数据传输?是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.

这篇关于网络上的大端或小端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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