Please build this for me, yesterday, also!
use Port::Authority;
Port::Authority would be a module which assigns and tracks ports for use with multiple application servers running on the same box. It would need an algorithm, capable of generating reproducible results, to generate port numbers in which are available, maybe it could be based on a namespace or random string + current user (etc), or maybe you could be able to specify the type of algorithm (e.g. UUID).
I need this yesterday for a variety of reason, what do you guys think?
According to daxim in #perl this already exists:
http://p3rl.org/Test::TCP#empty_port
Just a few days ago I extracted empty_port and _check_port from Test::TCP to use it in some 0mq project. Do you think it would make sense to publish a CPAN module that only implements empty_port?
I'd love something like that...
Finding an "empty_port" is trivial, and there are many ways to do it. Finding an "empty_port" is not the "hot dog" (essential part of the experience), the "hot dog" is in being able to "reproduce results".
For example, let's say you have an application server that gets checked-out of the repository and configured on multiple machines, sometimes on the same machine by multiple users.
Let's take it a step further and say that you want to automate configuration and deployment, continuously (buzzword, .. but seriously). Furthermore, let say you want other distributed applications to be able to talk to each other.
In this scenario, a "random" port doesn't work well, and a "static" port may have a conflict which impedes automation. An algorithmic approach allows all applications to be able to reasonably predict each other's listening port given a particular input.
If this makes any sense.
I've extracted to code into Net::EmptyPort and tokuhirom already release a TRIAL version of Test::TCP containing that module:
http://blog.64p.org/entry/2013/02/27/183549
Net::EmptyPort and Test::TCP both look great, I will use them.