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 committed Nov 3, 2023
1 parent 33c5bcc commit a58527a
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 a58527a

Please sign in to comment.