Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

In HTTPServer specification, Port:0 give error, should be Port:nil for kernel assigned ports #88

Open
gtaban opened this issue Nov 8, 2017 · 6 comments

Comments

@gtaban
Copy link
Collaborator

gtaban commented Nov 8, 2017

Based on comments from @helje5:
Don't do port: 0, should raise an error.
Do port: nil for kernel assigned, or a real port

@gtaban
Copy link
Collaborator Author

gtaban commented Nov 8, 2017

Based on discussions in #81

@seabaylea :

For 0 vs nil, the trade off is that allowing nil means using an Optional and having to do a whole bunch of nil checks. Rather than supporting 0 for random port (which is wrong as 0 is actually a reserved port), I think the question is whether there's a real need for kernel assigned port.

The kernel assign port is probably useful for testing, but is it required there (or for any other use cases)?

Helge:

Kernel assigned ports are very useful, I use them all the time for plenty of scenarios (backend servers, on-device per-app servers, etc.).
It is more like the other way around - assigned ports are only really useful for front facing servers. And whether Swift will replace Apache/NGINX/your-load-balance-of-choice soon is yet to be seen ;-) I mean,. we don't even have sendfile support (!), so you need something to deliver static resources efficiently anyways.

@gtaban gtaban changed the title Change Port:0 to Port: nil for kernel assigned ports In HTTPServer specification, Port:0 give error, should be Port:nil for kernel assigned ports Nov 8, 2017
@helje5
Copy link
Contributor

helje5 commented Nov 8, 2017

Just to be clear as this is missing from this issue: I don't care that much whether 0 or nil. But neither should be used, but addresses (which then may have similar issues).

@seabaylea
Copy link
Member

I think we got down to staying with 0 where you're setting point (in the convenience case vs. a full address), because it means we don't have to deal with Optionals and nil checks, and there's precedent with what's done elsewhere (Node.js, Golang, etc).

@gtaban
Copy link
Collaborator Author

gtaban commented Nov 8, 2017

C programmers are used to using 0 for randomly assigned ports by bind, however I can see why having a 0 might be confusing to a Swift programmer, new to kernel programming. However, making 0 give errors can be confusing to the C programmer.
I don't think the nil checks are that bad and they don't happen too frequently.

In all, given the changes proposed in #89 , this issue probably won't get us very much, so I propose we close it.

@gtaban
Copy link
Collaborator Author

gtaban commented Nov 10, 2017

Closing based on the above discussions.

@carlbrown
Copy link
Contributor

Referencing relevant comment from #81 :

#81 (comment)

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

No branches or pull requests

4 participants