Why connection failed for ipv6 in python?

Why connection failed for ipv6 ??

# python >>> import socket >>> s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) >>> sa = ('2000::1',2000,0,0) >>> s.connect(sa) >>> sa = ('fe80::21b:78ff:fe30:7c6', 2000, 0, 0) >>> s.connect(sa) Traceback (most recent call last): File "<stdin>", line 1, in ? File "<string>", line 1, in connect socket.error: (22, 'Invalid argument') 
+3
python sockets ipv6 connect
source share
1 answer

Local local links (e.g. fe80 :: whatever) usually require an identifier for the scope to work. Try

 sa = ('fe80::21b:78ff:fe30:7c6%en0', 2000, 0, 0) 

instead of this. (If the computer you are trying to connect to () is accessible through a network interface other than en0, replace the name of the interface where en0 is now located)

+6
source share

All Articles