为什么我用不了inet_ntop这个函数

tankfg 2009-06-03 09:57:00
最近搞IPV6的开发,可是我用不了inet_ntop 和 inet_pton这两个函数,而且msdn上也没有这两个函数的介绍。
我目前引入的头文件有这些。
#include <iostream>
#include <WinSock2.h>
#include <WS2tcpip.h>
在网上查到的好多要用
tpipv6.h这个头文件,但是再看安装过程的时候,都是说2k要安装那个补丁包,xp不需要啊。我现在操作系统是xp sp3.
往达人们指点一二。
...全文
3088 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
weikemin 2011-11-23
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 proad 的回复:]
这是Linux下专用函数。Windows下用inet_addr
[/Quote]

不错。
jim_brook 2009-08-15
  • 打赏
  • 举报
回复
二楼的同志,你好像说错了哟。
inet_addr 是把IPv4点分十进制地址串转换成网络字节序地址;
而inet_ntop 和 inet_pton这两个函数是用于IPv6的。
另外,楼主:msdn上有关于这两个函数的介绍,你没有找到,是因为你的msdn版本太低。建议到微软msdn网页上查询,能找到。

嘻嘻,不知所云。
tankfg 2009-06-03
  • 打赏
  • 举报
回复
哦,原来是这个样子啊,看来网上教程有的也靠不住啊。呵呵。
blackcat242 2009-06-03
  • 打赏
  • 举报
回复
哦,看错函数了
proad 2009-06-03
  • 打赏
  • 举报
回复
这是Linux下专用函数。Windows下用inet_addr
blackcat242 2009-06-03
  • 打赏
  • 举报
回复
Platform SDK: Windows Sockets 2
inet_ntoa
The inet_ntoa function converts an (Ipv4) Internet network address into a string in Internet standard dotted format.

char* FAR inet_ntoa(
struct in_addr in
);

Parameters
in
[in] Pointer to an in_addr structure that represents an Internet host address.
Return Values
If no error occurs, inet_ntoa returns a character pointer to a static buffer containing the text address in standard ".'' notation. Otherwise, it returns NULL.
Remarks
The inet_ntoa function takes an Internet address structure specified by the in parameter and returns an ASCII string representing the address in ".'' (dot) notation as in "a.b.c.d.'' The string returned by inet_ntoa resides in memory that is allocated by Windows Sockets. The application should not make any assumptions about the way in which the memory is allocated. The data is guaranteed to be valid until the next Windows Sockets function call within the same thread—but no longer. Therefore, the data should be copied before another Windows Sockets call is made.

Requirements
Client Requires Windows "Longhorn", Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server Requires Windows Server "Longhorn", Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header Declared in Winsock2.h.

Library Link to Ws2_32.lib.

DLL Requires Ws2_32.dll.

See Also
Winsock Reference, Winsock Functions, SOCKADDR, inet_addr

我的msdn中有描述

18,363

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧