Remove reliance on netstat / lsof to find an open port #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of parsing system calls to find an open port, an alternative implementation could use something like the portfinder package to find an open port regardless of the platform we are running on.
I initially referenced this issue in #16 as a niggle over using
lsof, which of course doesn't work on Windows. The workaround was to usenetstatfor a more platform-independent solution, however it still relies upongrep(which will fail on most Windows systems), and the whole situation feels hacky to me.We can avoid the whole try {systemCall} catch {doWork} pattern if we use something like portfinder.
For a trivial example, see monkpit@db43af5 . I'm sure the error handling could be made much more robust, I'm open to any suggestions 👍 😄