Skip to content

Instantly share code, notes, and snippets.

@systra
Created March 23, 2015 15:27
Show Gist options
  • Save systra/4b15931bad91254f3b3f to your computer and use it in GitHub Desktop.
Save systra/4b15931bad91254f3b3f to your computer and use it in GitHub Desktop.
Find free port
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