Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Dev for: Support IPv6 in PSWebSocketServer #50 #53

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

afbytes
Copy link

@afbytes afbytes commented Jun 27, 2016

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.

afbytes added 2 commits June 27, 2016 20:01
…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.
@robertjpayne
Copy link
Contributor

@afbytes thanks for this, I'm away on Holiday until August 1st, I'll check this when I get back!

@@ -48,6 +48,9 @@ @interface PSWebSocketServerConnection : NSObject
@end
@implementation PSWebSocketServerConnection

// private member variable
bool _isV6Address = false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have curly braces around it; otherwise it isn't an instance/member variable, it's a global variable.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

snej added a commit to couchbasedeps/PocketSocket that referenced this pull request Aug 18, 2016
}
addr.sin_port = htons(port);
_addrData = [NSData dataWithBytes:&addr length:sizeof(addr)];
_isV6Address = isV6Address;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants