参考地址:http://www.cnblogs.com/cslunatic/p/5816918.html
http://www.manew.com/forum.php?mod=viewthread&tid=90569&page=1#pid1111243
unity开发了一款游戏进行商品提交的时候被拒,原因我理解的是在ipv6的网络环境下无法进行和我们iipv4服务器进行沟通。但是ipv6的客户端是不能直接连接ipv4的服务端,而且国内的云服务器几乎没有ipv6地址。需要通过DNS64或者NAT64的转换地址才能连接。DNS64/NAT64是苹果提供的转换通道。
首先,查看苹果官方发布的IPv6过度技术。里面原理啦什么的说的很详细。https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW1
2.unity版本建议4.7.2版本以上。
3.2.1:打开新建的U3D调试工程,选择File菜单栏---->Build Settings----->IOS平台------->Ohter Settings----->Configuration---->Scriptiong Backend 选项(选择 IL2CPP) 以及 Architecture 选项(选择 Universal);
3.2.2:在苹果操作系统下新建一个 XCode(6.2以上) 工程--------->新建一个Object-C 文件------->新建的OC文件后缀 .m 更换为.mm文件 只为支持C/C++代码互编。接下来我们开始编写 苹果官方给出的 兼容代码。
3.2.2.1:代码如下:
#import <sys/socket.h> #import <netdb.h> #import <arpa/inet.h> #import <err.h> #define MakeStringCopy( _x_ ) ( _x_ != NULL && [_x_ isKindOfClass:[NSString class]] ) ? strdup( [_x_ UTF8String] ) : NULL |
extern "C"{
const char* getIPv6(const char *mHost,const char *mPort)
{
if( nil == mHost )
return NULL;
const char *newChar = "No";
const char *cause = NULL;
struct addrinfo* res0;
struct addrinfo hints;
struct addrinfo* res;
int n, s;
memset(&hints, 0, sizeof(hints));
&