MCPcopy Create free account
hub / github.com/microsoft/debugpy / get_default_localhost

Function get_default_localhost

src/debugpy/common/sockets.py:36–50  ·  view source on GitHub ↗

Get the default localhost address. Defaults to IPv4 '127.0.0.1', but falls back to IPv6 '::1' if IPv4 is unavailable.

()

Source from the content-addressed store, hash-verified

34 return False
35
36def get_default_localhost():
37 """Get the default localhost address.
38 Defaults to IPv4 '127.0.0.1', but falls back to IPv6 '::1' if IPv4 is unavailable.
39 """
40 # First try IPv4 (preferred default)
41 if can_bind_ipv4_localhost():
42 return "127.0.0.1"
43
44 # Fall back to IPv6 if IPv4 is not available
45 if can_bind_ipv6_localhost():
46 return "::1"
47
48 # If neither works, still return IPv4 as a last resort
49 # (this is a very unusual situation)
50 return "127.0.0.1"
51
52def get_address(sock):
53 """Gets the socket address host and port."""

Callers 1

create_serverFunction · 0.85

Calls 2

can_bind_ipv4_localhostFunction · 0.85
can_bind_ipv6_localhostFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…