htonl htons ntohs ntohl四个函数的粗浅理解
来源:互联网 发布:多益网络账号格式错误 编辑:程序博客网 时间:2024/06/12 01:25
我在学习APUE这本书的过程中,一直对什么是大端字节序和小端字节序很迷糊,今天专门抽出一点时间来仔细的搞清楚这个问题。同时将学的一些东西写下来,让想学习的好友或者是朋友都了解一下。
int htonl(int ) :将主机字节序转换成网络字节序。
具体的转换流程请看转载链接::http://blog.sina.com.cn/s/blog_63e60ca50101byk3.html。
下面是一个程序的具体实现过程,帮助大家更清楚的了解一下。
#include<arpa/inet.h>
#include<stdio.h>
int main()
{
int host=htons(0x1F28);
printf("host=%x\n",host);
return 0;
}
使用gcc编译过后,大家会发现结果是0x281F。
由于TCP/IP 协议的网络字节序是大端地址。因此我们可以发现我采用的机子是小端地址。同时我们可以了解到所有这些函数的目的就是将你输入的地址序列转换成大端字节序。
- htonl htons ntohs ntohl四个函数的粗浅理解
- htonl(), ntohl(), htons(), ntohs() 函数
- htonl(), ntohl(), htons(), ntohs() 函数
- htonl(), ntohl(), htons(), ntohs() 函数
- htons(), htonl(), ntohs(), ntohl()
- ntohs(),ntohl(),htons(),htonl(),
- htons(), htonl(), ntohs(), ntohl()
- htons(), htonl(), ntohs(), ntohl()
- htons,htonl,ntohs,ntohl
- htons(), htonl(), ntohs(), ntohl()
- htonl(), ntohl(), htons(), ntohs().
- htons,htonl,ntohs,ntohl
- htonl ntohl htons ntohs
- htons ntohs htonl ntohl
- htonl、htons、ntohl、ntohs
- ntohs, ntohl, htons,htonl
- ntohs,htons,ntohl,htonl
- 关于htons(),htonl(),ntohl(),ntohs()函数的备忘
- 如何改变beamer中itemize标记的颜色
- ruby介绍的好博客
- git stash笔记
- Json后台转换
- IP首部结构及组包算法分析
- htonl htons ntohs ntohl四个函数的粗浅理解
- 深入浅出MFC笔记2-MFC程序如何包装Win32程序
- bugzilla的report中文乱码问题
- android 删除文件,打开指定的文件类型
- VS2010下Team Foundation Server连接不上
- linux shell 字符串操作(长度,查找,替换)详解
- 使用WakeLock使Android应用程序保持后台唤醒
- Linux系列-文件系统基本结构和文件基本操作管理
- 开源游戏学习- 模拟系统的架构设计