Connect Fail with IPv6 on client side.

0 votes

Hi!

I use AppWarpClient from this link.

But I think it does not support IPv6. Apple reject my next iOS app version due to their new policy.

I modify some code at socket connect according to Apple Link.

Here is my code:

int Socket::sockConnect(std::string host, short port)
{
struct addrinfo hints;
struct addrinfo *result, *rp;
int s;

/* Obtain address(es) matching host/port */

memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;    /* Allow IPv4 or IPv6 */
hints.ai_socktype = SOCK_STREAM; /* stream socket */
hints.ai_flags = 0;
hints.ai_protocol = 0;          /* Any protocol */

s = getaddrinfo(host.c_str(), to_string(port).c_str(), &hints, &result);
if (s != 0)
{
CCLOG("ConsoleUploadFile: getaddrinfo error");
return AppWarp::result_failure;
}

for (rp = result; rp != nullptr; rp = rp->ai_next) {
sockd = socket(rp->ai_family, rp->ai_socktype,
rp->ai_protocol);
if (sockd == -1)
continue;

if (connect(sockd, rp->ai_addr, rp->ai_addrlen) != -1)
break;                  /* Success */

close(sockd);
}

if (rp == nullptr) {               /* No address succeeded */
return AppWarp::result_failure;
}

freeaddrinfo(result);           /* No longer needed */
fcntl(sockd, F_SETFL, O_NONBLOCK);

return AppWarp::result_success;
}

Would you please help me fix this?

Thanks.

asked Jul 19, 2016 in AppWarpS2 by 9 Knight Studio (16 points)

1 Answer

+1 vote
 
Best answer
Hi,

I have forwarded this to our development team and will update you on the same as soon as possible.

Meanwhile, could you please let me know which Cocos2dx version you are using for your project? It will help us to provide you better support from our side.

Regards,

Rajeev Ranjan
answered Jul 19, 2016 by rajeev.etc (1,660 points)
selected Aug 3, 2016 by 9 Knight Studio
Hi!

Thanks for your reply.

I'm using cocos2d-x 3.8 for developing. Beside, I've updated some new third party libs (websocket, curl, ...). Http request works fine with IPv6, but socket connect does not.

Looking forward your update.

Regards.
Hi,

I have modified the SDK to support IPv6 and same can be downloaded from here( https://www.dropbox.com/s/4nmvv1ntvvr0e57/AppWarpS2X.zip?dl=0 ).
Please check the same at your end and let me know if you face any issues.

Regards,
Rajeev
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...