findNextAvailableSync
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.
NOTE: This is a blocking call and should be invoked from a background thread.
Parameters
host
either LocalHost.IPv4 or LocalHost.IPv6
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 the check fails (e.g. calling from Main thread on Android)