find_remote_unused_ports#
- Session.find_remote_unused_ports(count: int, start: int | None = None, end: int | None = None, avoid: list[int] | None = None) List[int] | None #
Find “count” unused ports on the host system. A port is considered unused if it does not respond to a “connect” attempt. Walk the ports from ‘start’ to ‘end’ looking for unused ports and avoiding any ports in the ‘avoid’ list. Stop once the desired number of ports have been found. If an insufficient number of ports were found, return None. An admin user check is used to skip [1-1023].
- Parameters:
- count: int
number of unused ports to find
- start: int
the first port to check or None (random start)
- end: int
the last port to check or None (full range check)
- avoid: list
an optional list of ports not to check
- Returns:
the
detected
ports
orNone
on
failure