htons
htons的功能
htons函数用来转换u_short了来自主机的TCP / IP网络字节顺序(即big-endian )的.
u_short htons ( u_short hostshort ) ;
参数hostshort [ ] 16位元数的主机字节顺序. 返
回值的htons函数返回值的TCP / IP网络字节顺序.
须知htons函数有一个16位号码主机字节顺序并返回一个16位数字网络字节 命令中使用的TCP / IP网络.
编写了如下的程序:只是为了测试htons的输出结果
#include "stdafx.h"
#include <windows.h>
#include <WINSOCK2.H>
#progmma comment(lib, "ws2_32.lib")
int main(int argc, char* argv[])
{
printf("%d" , htons(16));
return 0;
}