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

second attempt: empty_port_multi #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dakkar
Copy link

@dakkar dakkar commented Jul 5, 2013

now with more documentation

Calling "empty_port" repeatedly does not guarantee you get different
ports each time, which is a problem if you need a few ports you're going
to listen on later. It's not always feasible to guarantee the correct
interleaving of calls to empty_port with socket creation, so we need a
way to get a bunch of open ports.
@dakkar
Copy link
Author

dakkar commented Jul 5, 2013

ok, sometimes I'm an idiot. I had left the "die" in the wrong place. Now the code does what the documentation says.

@JJ
Copy link

JJ commented Jan 2, 2015

Any reason why this is still open?

@kazuho
Copy link
Collaborator

kazuho commented Apr 2, 2015

@dakkar

Calling "empty_port" repeatedly does not guarantee you get different ports each time

How about doing something like:

my $port1 = empty_port();
my $port2 = empty_port($port1 + 1);

@dakkar
Copy link
Author

dakkar commented Apr 8, 2015

@kazuho sure, that will work, but it's based on an internal implementation detail: nowhere the documentation says you get back the lowest empty port number in the interval requested. Maybe you get the highest one, or a random one… at the very least the implemented behaviour should be documented.

@nponeccop
Copy link
Collaborator

Nope that won't work. If $port is free it doesn't mean that $port + 1 is also free.

Few solutions exist though:

So I vote for closing this PR

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.

4 participants