Skip to content

Instantly share code, notes, and snippets.

@kapkaev
Created September 10, 2019 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kapkaev/d51c62d0ebda504925f6c28d0c1e9b97 to your computer and use it in GitHub Desktop.
Save kapkaev/d51c62d0ebda504925f6c28d0c1e9b97 to your computer and use it in GitHub Desktop.
def findAvailablePort(): Int = {
val socket = new ServerSocket(0)
socket.setReuseAddress(true)
val port = socket.getLocalPort
socket.close()
port
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment