corda / net.corda.testing.core / getFreeLocalPorts


fun getFreeLocalPorts(hostName: String, numberToAlloc: Int): List<NetworkHostAndPort>
Deprecated: Returned port is not guaranteed to be free when used, which can result in flaky tests. Instead use a port range that's unlikely to be used by the rest of the system, such as PortAllocation.Incremental(10000).

Creates a specified number of ports for use by the Node.

Unlikely, but in the time between running this function and handing the ports to the Node, some other process else could allocate the returned ports.