Open
Description
Bug report
1、Test Code:
from multiprocessing.connection import Client
address = ('fe80::01',9999,0,0)
with Client(address,family='AF_INET6', authkey=b'1') as conn:
print(conn.recv())
2、Error message
Traceback (most recent call last):
File "c:\Users\Tiger\Desktop\http\c.py", line 5, in <module>
with Client(address,family='AF_INET6', authkey=b'1') as conn:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Tiger\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\connection.py", line 501, in Client
c = SocketClient(address)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Tiger\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\connection.py", line 629, in SocketClient
s.connect(address)
TypeError: AF_INET address must be a pair (host, port)
3、Causes and Solutions
Snippets of code in lib/multiprocessing/connection.py
def address_type(address):
'''
Return the types of the address
This can be 'AF_INET', 'AF_UNIX', or 'AF_PIPE'
'''
if type(address) == tuple:
return 'AF_INET'
elif type(address) is str and address.startswith('\\\\'):
return 'AF_PIPE'
elif type(address) is str or util.is_abstract_socket_namespace(address):
return 'AF_UNIX'
else:
raise ValueError('address type of %r unrecognized' % address)
An ipv6 address is a four-tuple,the code for the following sentence should be perfected
if type(address) == tuple:
return 'AF_INET'
The modified code is as follows:
if type(address) == tuple:
if len(address)==2:
return 'AF_INET'
else:
return 'AF_INET6'
That's all, ok!
4、A more complete solution
"lib/multiprocessing/connection.py"
Modify the SocketClient function,add parameters family,......
def SocketClient(address,family=None):

