Skip to content

Instantly share code, notes, and snippets.

@kapkaev
Created September 10, 2019 00:15
Show Gist options
  • 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