spring-framework / org.springframework.util / SocketUtils / findAvailableUdpPort

findAvailableUdpPort

open static fun findAvailableUdpPort(): Int

Find an available UDP port randomly selected from the range [{@value #PORT_RANGE_MIN}, {@value #PORT_RANGE_MAX}].

Exceptions

IllegalStateException - if no available port could be found

Return
an available UDP port number

open static fun findAvailableUdpPort(minPort: Int): Int

Find an available UDP port randomly selected from the range [minPort, {@value #PORT_RANGE_MAX}].

Parameters

minPort - the minimum port number

Exceptions

IllegalStateException - if no available port could be found

Return
an available UDP port number

open static fun findAvailableUdpPort(minPort: Int, maxPort: Int): Int

Find an available UDP port randomly selected from the range [minPort, maxPort].

Parameters

minPort - the minimum port number

maxPort - the maximum port number

Exceptions

IllegalStateException - if no available port could be found

Return
an available UDP port number