Dev for: Support IPv6 in PSWebSocketServer #50#53
Dev for: Support IPv6 in PSWebSocketServer #50#53afbytes wants to merge 2 commits intozwopple:developfrom
Conversation
…oth. E.g., nil (4+6), "0.0.0.0"(4+6), "::"(4+6), 127.0.0.1"(4), "::1"(6), "192.168.1.10"(4) etc.
|
@afbytes thanks for this, I'm away on Holiday until August 1st, I'll check this when I get back! |
| @implementation PSWebSocketServerConnection | ||
|
|
||
| // private member variable | ||
| bool _isV6Address = false; |
There was a problem hiding this comment.
This should have curly braces around it; otherwise it isn't an instance/member variable, it's a global variable.
There was a problem hiding this comment.
Also, it should be declared in PSWebSocketServer, not PSWebSocketServerConnection.
And you can't initialize an instance variable in its declaration, so the = false needs to be deleted.
From zwopple#53 with minor fixes For couchbase/couchbase-lite-ios#1238
| } | ||
| addr.sin_port = htons(port); | ||
| _addrData = [NSData dataWithBytes:&addr length:sizeof(addr)]; | ||
| _isV6Address = isV6Address; |
There was a problem hiding this comment.
This is wrong: If isV6Address is false but isAnyAddress is true, then _addrData will contain an IPv6 address, so the CFSocketCreate call below needs to pass PF_INET6.
I fixed this by removing this line and adding _isV6Address = YES at the end of the IPv6 branch above (after line 151 in this patch.)
Support specifying the web socket server to listen on IPv4, IPv6 or both. E.g., nil (4+6), "0.0.0.0"(4+6), "::"(4+6), 127.0.0.1"(4), "::1"(6), "192.168.1.10"(4) etc.