本文包括了微软公司对 winsock 编程时可能发生的ipv4与ipv6的兼容问题的解释说明.
数据结构差异参考 【程序编程相关:去除默认共享】
http://msdn.microsoft.com/library/default.html?url=/library/en-us/winsock/winsock/changing_data_structures_2.html 【推荐阅读:木马的检测、清除与防范】
changing data structures 【扩展信息:phpMyAdmin 2.6 傻瓜设置4】
platform sdk: windows sockets 2
when adding ipv6 functionality, you must ensure that your application defines properly sized data structures. the size of an ipv6 address is much larger than an ipv4 address. structures that are hard-coded to handle the size of an ipv4 address when storing an ip address will cause problems in your application, and must be modified.
best practice
the best approach to ensuring that your structures are properly sized is to use the sockaddr_storage structure. the sockaddr_storage structure is agnostic to ip address version. when the sockaddr_storage structure is used to store ip addresses, ipv4 and ipv6 addresses can be properly handled with one code base.
the following example, which is an excerpt taken from the server.c file found in appendix b, identifies an appropriate use of the sockaddr_storage structure. notice that the structure, when used properly as this example shows, gracefully handles either an ipv4 or ipv6 address.
... 下一页