findNextAvailableAsync

expect suspend fun Port.Ephemeral.findNextAvailableAsync(limit: Int, host: LocalHost): Port.Ephemeral(source)

Finds an available TCP port on LocalHost starting with the current Port.Ephemeral.value and iterating up limit times.

If Port.Ephemeral.MAX is exceeded while iterating through ports and limit has not been exhausted, the remaining checks will start from Port.Ephemeral.MIN.

Parameters

limit

the number of ports to scan. min: 1, max: 1_000

See also

io.matthewnelson.kmp.tor.runtime.core.util.findAvailableSync

Throws

IllegalArgumentException

if limit is not between 1 and 1_000 (inclusive)

if no ports are available

CancellationException

if underlying coroutine was cancelled

actual suspend fun Port.Ephemeral.findNextAvailableAsync(limit: Int, host: LocalHost): Port.Ephemeral(source)

Finds an available TCP port on LocalHost starting with the current Port.Ephemeral.value and iterating up limit times.

If Port.Ephemeral.MAX is exceeded while iterating through ports and limit has not been exhausted, the remaining checks will start from Port.Ephemeral.MIN.

Parameters

limit

the number of ports to scan. min: 1, max: 1_000

Throws

IllegalArgumentException

if limit is not between 1 and 1_000 (inclusive)

if no ports are available

CancellationException

if underlying coroutine was cancelled

actual suspend fun Port.Ephemeral.findNextAvailableAsync(limit: Int, host: LocalHost): Port.Ephemeral(source)

Finds an available TCP port on LocalHost starting with the current Port.Ephemeral.value and iterating up limit times.

If Port.Ephemeral.MAX is exceeded while iterating through ports and limit has not been exhausted, the remaining checks will start from Port.Ephemeral.MIN.

Parameters

limit

the number of ports to scan. min: 1, max: 1_000

See also

Throws

IllegalArgumentException

if limit is not between 1 and 1_000 (inclusive)

if no ports are available

CancellationException

if underlying coroutine was cancelled