gruntjs / grunt-contrib-connect

Start a static web server.
http://gruntjs.com
MIT License
714 stars 146 forks source link

Don't pass port 0 to portscanner #166

Closed mzgoddard closed 9 years ago

mzgoddard commented 9 years ago

iojs and 0.12 error if Socket.connect receives port 0. https://github.com/joyent/node/blob/master/lib/net.js#L901

grunt-contrib-connect needs to make sure not to pass port 0. This might just need to be updating tests and documenting this but maybe some changes to the task too.

sindresorhus commented 9 years ago

This is a Node issue. This used to work and is a regression in Node.

https://github.com/joyent/node/issues/9194

mzgoddard commented 9 years ago

@sindresorhus Its a regression in Node but its pretty intentional and gives a clearer error than the prior EADDRNOTAVAIL. Even if its a regression in Node, it seems incorrect to me that the code even tries to check port 0 with portscanner. portscanner checks ports by attempting to connect to them and in Node's case it doesn't make sense to bind to port 0 thinking it'll actually be port 0 instead of resulting in a random port. portscanner will always say that port 0 is available.

This appears to me as a misuse of portscanner.

sindresorhus commented 9 years ago

This happens even without portscanner. portscanner is for the https://github.com/gruntjs/grunt-contrib-connect#useavailableport option, setting port to 0 is to get a random port. Different.