Only attempt to set IPV6_V6ONLY for IPv6 sockets
This commit is contained in:
parent
720f69e888
commit
4b35a63562
1 changed files with 6 additions and 4 deletions
2
neomi.py
2
neomi.py
|
@ -36,6 +36,8 @@ def bind(port, backlog = 1):
|
||||||
s = socket.socket(af, socktype, proto)
|
s = socket.socket(af, socktype, proto)
|
||||||
except OSError:
|
except OSError:
|
||||||
continue
|
continue
|
||||||
|
# Make IPv6 socket only bind on IPv6 address, otherwise may clash with IPv4 and not get enabled
|
||||||
|
if af == socket.AF_INET6:
|
||||||
try:
|
try:
|
||||||
s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
|
s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|
Loading…
Reference in a new issue