Created
March 23, 2015 15:27
-
-
Save systra/4b15931bad91254f3b3f to your computer and use it in GitHub Desktop.
Find free port
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find_free_port() -> | |
{ok, X} = gen_tcp:listen(0, [{active, false}]), | |
{ok, P} = inet:port(X), | |
gen_tcp:close(X), | |
{ok, P} | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment