MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / port_is_available

Function port_is_available

start_webui.py:190–198  ·  view source on GitHub ↗
(host: str, port: int)

Source from the content-addressed store, hash-verified

188
189
190def port_is_available(host: str, port: int) -> bool:
191 probe_host = host or "0.0.0.0"
192 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
193 sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
194 try:
195 sock.bind((probe_host, port))
196 return True
197 except OSError:
198 return False
199
200
201def resolve_available_port(host: str, preferred_port: int, max_scan: int = 100) -> int:

Callers 1

resolve_available_portFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected