最近搞IPV6的开发,可是我用不了inet_ntop 和 inet_pton这两个函数,而且msdn上也没有这两个函数的介绍。
我目前引入的头文件有这些。
#include <iostream>
#include <WinSock2.h>
#include <WS2tcpip.h>
在网上查到的好多要用
tpipv6.h这个头文件,但是再看安装过程的时候,都是说2k要安装那个补丁包,xp不需要啊。我现在操作系统是xp sp3.
往达人们指点一二。

解决方案 »

  1.   

      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.
    Res
    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中有描述
      

  2.   

    这是Linux下专用函数。Windows下用inet_addr
      

  3.   

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