consensus-network/src/main/java/com/mboysan/consensus/util/NettyUtil.java
/**
     * Taken from: <a href="https://gist.github.com/vorburger/3429822">vorburger/gist:3429822</a>
     * Returns a free port number on localhost.
     * @return a free port number on localhost
     * @throws IllegalStateException if unable to find a free port
     */
Taken from: vorburger/gist:3429822
Returns a free port number on localhost.
@return a free port number on localhost
@throws IllegalStateException if unable to find a free port
Taken from : vorburger / gist : 3429822 Returns a free port number on localhost . @return a free port number on localhost @throws IllegalStateException if unable to find a free port
public static int findFreePort() {
        try (ServerSocket socket = new ServerSocket(0)) {
            socket.setReuseAddress(true);
            return socket.getLocalPort();
        } catch (IOException e) {
            throw new IllegalStateException("Could not find a free TCP/IP port.", e);
        }
    }
public static int findFreePort ( ) { try ( ServerSocket socket = new ServerSocket ( 0 ) ) { socket . setReuseAddress ( true ) ; return socket . getLocalPort ( ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Could not find a free TCP/IP port." , e ) ; } }
Taken from: <a href="https://gist.github.com/vorburger/3429822">vorburger/gist:3429822</a>
 Returns a free port number on localhost.
Taken from : <a href = " https : // gist . github . com / vorburger / 3429822 " > vorburger / gist : 3429822< / a > Returns a free port number on localhost .