Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

底层socket 支持ip6问题

$
0
0

@lovekankan 写道:

    struct sockaddr_in6 dest;
    if ((m_sockClient = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
    {
        printf("ipv6,未连接");// IPv6
    }
    printf("socket Ok!");
    
    bzero(&dest, sizeof(dest));
    dest.sin6_family = AF_INET6;     // IPv6
    dest.sin6_port = htons(nServerPort);     // IPv6
    if (inet_pton(AF_INET6, domainToIP(pszServerIP).c_str(), &dest.sin6_addr) < 0 ) {                 // IPv6
        return false;
    }
    printf("address created/n");
    
    int ret = connect(m_sockClient, (struct sockaddr *) &dest, sizeof(dest));
    if ( ret == SOCKET_ERROR ) {
        int ell = errno;
        printf("%d", errno);
        return false;
    }

使用如上代码进行socket connect时失败,这个是不是要改服务器代码才能连接成功啊(服务器代码还是之前连ip4的代码)

帖子: 2

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>