Skip to content

Commit

Permalink
Prefer IPv4 over IPv6 for dual-stack sockets.
Browse files Browse the repository at this point in the history
  • Loading branch information
markov authored and fabioz committed Feb 10, 2024
1 parent 34c9f24 commit 262e341
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions _pydevd_bundle/pydevd_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,13 @@ def start_client(host, port):

address_family = AF_INET
for res in socket_module.getaddrinfo(host, port, 0, SOCK_STREAM):
if res[0] == AF_INET6:
# Prefer IPv6 addresses.
if res[0] == AF_INET:
address_family = res[0]
# Prefer IPv4 addresses for backward compat.
break
if res[0] == AF_INET6:
# Don't break after this - if the socket is dual-stack prefer IPv4.
address_family = res[0]

s = socket(address_family, SOCK_STREAM)

Expand Down

0 comments on commit 262e341

Please sign in to comment.