Skip to content

getRandomEphemeralPort

getRandomEphemeralPort(): PortNumber

Defined in: packages/net-address/src/port/ephemeral-port.ts:20

A random port from the range RFC 6335 and IANA set aside for dynamic or private use, 49152 through 65535.

Drawn from crypto.getRandomValues, so it is unpredictable — which matters when the port is a weak secret, as an ephemeral source port is. It says nothing about whether the port is free; binding is still the only test.

PortNumber