【C++】inet_ptoa&inet_atop inet_pton&inet_ntop

来源:互联网 发布:js是什么防水材料 编辑:程序博客网 时间:2024/06/07 04:52
  • inet_aton、inet_addr和inet_ntoa在点分十进制数串(例如”206.62.226.33”)与它的32位网络字节序二进制值间转换IPv4地址
  • 两个较新的函数:inet_pton和inet_ntop对IPv4和IPv6地址都能进行处理
/* Convert Internet number in IN to ASCII representation.  The return value   is a pointer to an internal array containing the string.  */extern char *inet_ntoa (struct in_addr __in) __THROW;/* Convert from presentation format of an Internet number in buffer   starting at CP to the binary network format and store result for   interface type AF in buffer starting at BUF.  */extern int inet_pton (int __af, const char *__restrict __cp,              void *__restrict __buf) __THROW;/* Convert a Internet address in binary network format for interface   type AF in buffer starting at CP to presentation form and place   result in buffer of length LEN astarting at BUF.  */extern const char *inet_ntop (int __af, const void *__restrict __cp,                  char *__restrict __buf, socklen_t __len)     __THROW;/* The following functions are not part of XNS 5.2.  */#ifdef __USE_MISC/* Convert Internet host address from numbers-and-dots notation in CP   into binary data and store the result in the structure INP.  */extern int inet_aton (const char *__cp, struct in_addr *__inp) __THROW;

引用图:http://m.blog.csdn.net/u011068702/article/details/61219662
这里写图片描述

原创粉丝点击