Wie erstelle ich einen IPv6-Socket bei Python? Warum wurde die Datei socket.error: (22, 'Ungültiges Argument') ausgegeben?

Ich möchte Ipv6-Socket bei Python ceate, ich mache es so:

#!/usr/bin/env python
import sys
import struct
import socket

host = 'fe80::225:b3ff:fe26:576'
sa = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
sa.bind((host , 50000))

Aber es ist fehlgeschlagen:

socket.error: (22, 'Invalid argument') ?

Kann mir jemand helfen? Vielen Dank

Ich wiederhole es so, kann aber immer noch nicht funktionieren

    >>>host = 'fe80::225:b3ff:fe26:576'
    >>>sa = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
    >>>res = socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_DGRAM, 0, socket.AI_PASSIVE)
    >>>family, socktype, proto, canonname, sockaddr = res[0]
    >>>print sockaddr
('fe80::225:b3ff:fe26:576', 50001, 0, 0)
    >>>sa.bind(sockaddr)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<string>", line 1, in bind
socket.error: (22, 'Invalid argument')

Antworten auf die Frage(4)

Ihre Antwort auf die Frage