Connect Fail with IPv6 on client side.

0 votes


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,
if (sockd == -1)

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


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?


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

1 Answer

+1 vote
Best answer

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.


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

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.


I have modified the SDK to support IPv6 and same can be downloaded from here( ).
Please check the same at your end and let me know if you face any issues.

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