- 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
这篇博客介绍了C++中用于IPv4地址转换的函数,包括inet_aton、inet_addr、inet_ntoa以及较新的inet_pton和inet_ntop。这些函数用于在点分十进制字符串和32位网络字节序二进制值之间进行转换,并且inet_pton和inet_ntop还支持IPv6地址。文章包含详细说明和相关链接。

8181

被折叠的 条评论
为什么被折叠?



