htons


 

#include <arpa/inet.h>
uint16_t htons(uint16_t hostshort);

htons的功能:将一个无符号短整型数值转换为网络字节序,即大端模式(big-endian)
参数u_short hostshort: 16位无符号整数
返回值:TCP / IP网络字节顺序.


 

功能:将一个点分十进制的IP转换成一个长整数型数(u_long类型)
原型:in_addr_t inet_addr(const char *cp);  
参数:字符串,一个点分十进制的IP地址
返回值
如果正确执行将返回一个无符号长整数型数。如果传入的字符串不是一个合法的IP地址,将返回INADDR_NONE。
头文件:Winsock2.h.
arpa/inet.h(Linux)

相关文章:

  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2022-02-10
  • 2022-12-23
相关资源
相似解决方案