Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/SametDEDE/CocoaAsyncSocket
Browse files Browse the repository at this point in the history
…into ipv6

Credit to @Smeegol: #429 (comment)

Confirmed as bug in getaddrinfo by Apple staff (rdar://26365575): https://forums.developer.apple.com/thread/47312#138895
  • Loading branch information
chrisballinger committed Jun 17, 2016
2 parents 7877b0a + ed8bfaf commit 640d21c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Source/GCD/GCDAsyncSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -8155,9 +8155,18 @@ + (NSMutableArray *)lookupHost:(NSString *)host port:(uint16_t)port error:(NSErr
}
else if (res->ai_family == AF_INET6)
{
// Fixes connection issues with IPv6
// https://github.com/robbiehanson/CocoaAsyncSocket/issues/429#issuecomment-222477158

// Found IPv6 address.
// Wrap the native address structure, and add to results.

struct sockaddr_in6 *sockaddr = (struct sockaddr_in6 *)res->ai_addr;
in_port_t *portPtr = &sockaddr->sin6_port;
if ((portPtr != NULL) && (*portPtr == 0)) {
*portPtr = htons(port);
}

NSData *address6 = [NSData dataWithBytes:res->ai_addr length:res->ai_addrlen];
[addresses addObject:address6];
}
Expand Down

0 comments on commit 640d21c

Please sign in to comment.