Skip to content

Conversation

hdgarrood
Copy link
Member

No description provided.

@paf31
Copy link
Contributor

paf31 commented Nov 10, 2016

Looks good to me, but do you think we should consider using Data.Options here?

@hdgarrood
Copy link
Member Author

I don't think so, since the node API takes positional arguments.

@paf31
Copy link
Contributor

paf31 commented Nov 10, 2016

Does this cover all of them now?

@hdgarrood
Copy link
Member Author

Oh yeah oops - there are two additional ways of calling this that this PR doesn't cover. There is another optional argument, which is the maximum length of the queue of pending connections (an integer). You can also supply a file name instead of a port and hostname in order to have the server listen on a unix socket, apparently. I think the unix socket version should maybe be a separate function, though.

Also you can omit the port to have a random OS-assigned port, so it might make sense for the purescript api to allow you to omit the port too?

@hdgarrood
Copy link
Member Author

Maybe Data.Options does make more sense, actually. I'll update this.

@hdgarrood
Copy link
Member Author

Annoyingly, if you want to supply a hostname, you have to supply a port too, because it uses optional positional arguments. Likewise, if you want to supply a backlog, you have to supply both a hostname and a port. So Data.Options isn't really going to work after all, I think. I think we should just make hostname and port compulsory, and backlog a Maybe.

@paf31
Copy link
Contributor

paf31 commented Nov 10, 2016

You could use Divisible to accept a Tuple Hostname Port, perhaps.

@hdgarrood
Copy link
Member Author

Right, but Data.Options only works well when most things are actually optional, and in particular when the presence of some things doesn't depend on the presence of other things. Even with Divisible it would still be possible to only supply a backlog, which we wouldn't be able to do anything with.

@paf31
Copy link
Contributor

paf31 commented Nov 10, 2016

Annoyingly, if you want to supply a hostname, you have to supply a port too, because it uses optional positional arguments.

You can't use undefined?

@hdgarrood
Copy link
Member Author

Nope:

> var s = http.createServer(() => {})
> s.listen(undefined, undefined, 500)
RangeError: "port" argument must be >= 0 and < 65536
    at assertPort (internal/net.js:17:11)
    at Server.listen (net.js:1388:5)
    at repl:1:3
    at sigintHandlersWrap (vm.js:22:35)
    at sigintHandlersWrap (vm.js:96:12)
    at ContextifyScript.Script.runInThisContext (vm.js:21:12)
    at REPLServer.defaultEval (repl.js:313:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:513:10)

@hdgarrood
Copy link
Member Author

(node.js v6.9.1)

@paf31
Copy link
Contributor

paf31 commented Nov 10, 2016

👍 LGTM

@hdgarrood
Copy link
Member Author

Thanks for the review!

@hdgarrood hdgarrood merged commit 0020da1 into master Nov 10, 2016
@hdgarrood hdgarrood deleted the listen-hostname branch November 10, 2016 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants