-
-
Save apeckham/78da0a59076a4b91b1f5acf40a96de69 to your computer and use it in GitHub Desktop.
find free port in clojure
This file contains 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
(defn get-free-port [] | |
(with-open [socket (ServerSocket. 0)] | |
(.getLocalPort socket))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BTW, you can use
with-open
instead oflet
to get theclose
call for free.