Skip to content

Instantly share code, notes, and snippets.

@kapkaev
Created September 10, 2019 00:15
Embed
What would you like to do?
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