Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get multiple ports via number option #49

Closed
silverwind opened this issue Oct 15, 2020 · 2 comments
Closed

Get multiple ports via number option #49

silverwind opened this issue Oct 15, 2020 · 2 comments

Comments

@silverwind
Copy link

silverwind commented Oct 15, 2020

I'd like to get two or more free ports in the full range of ports with the assignment mechanism than getPort().

Now there is getPort.makeRange(1024, 65535) and calling .next() multiple times achieves a similar result but it's not exactly the same as getPort() because ports are assigned sequentially from the start argument.

I'd suggest a number option that that if passed changes the signature of the return value to an Array of port.

@silverwind
Copy link
Author

silverwind commented Oct 15, 2020

Actually, it seems getPort() may already be suitable if it can guarantee that it will never return the same port on subsequent calls:

> await getPort()
51161
> await getPort()
51162

Is this guarantee true? What happens if the port space is exhausted?

@silverwind
Copy link
Author

Actually, I think I can answer myself. It should reject if port space is exhausted (.listen will fail).

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

No branches or pull requests

1 participant