Skip to content

Commit

Permalink
Debug host processes that already support IPv6.
Browse files Browse the repository at this point in the history
This change will allow pydevd to start with `--client <IPv6-host>` and connect to them.
  • Loading branch information
markov authored Nov 2, 2023
1 parent 2cf10e3 commit 33c5bcc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions _pydevd_bundle/pydevd_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@
from _pydevd_bundle.pydevd_comm_constants import * # @UnusedWildImport

# Socket import aliases:
AF_INET, SOCK_STREAM, SHUT_WR, SOL_SOCKET, IPPROTO_TCP, socket = (
AF_INET, AF_INET6, SOCK_STREAM, SHUT_WR, SOL_SOCKET, IPPROTO_TCP, socket = (
socket_module.AF_INET,
socket_module.AF_INET6,
socket_module.SOCK_STREAM,
socket_module.SHUT_WR,
socket_module.SOL_SOCKET,
Expand Down Expand Up @@ -463,7 +464,14 @@ def start_client(host, port):
''' connects to a host/port '''
pydev_log.info("Connecting to %s:%s", host, port)

s = socket(AF_INET, SOCK_STREAM)
address_family = AF_INET
for res in socket_module.getaddrinfo(host, port, 0, SOCK_STREAM):
if res[0] == AF_INET6:
# Prefer IPv6 addresses.
address_family = res[0]
break

s = socket(address_family, SOCK_STREAM)

# Set TCP keepalive on an open socket.
# It activates after 1 second (TCP_KEEPIDLE,) of idleness,
Expand Down

0 comments on commit 33c5bcc

Please sign in to comment.