Fix '[Errno 22] Invalid argument' caused by IPv6 socket without IPv4 support

This commit is contained in:
Stein Magnus Jodal 2010-09-12 16:38:18 +02:00
parent d6798ac870
commit 4ad476e1e5

View File

@ -24,6 +24,9 @@ class MpdServer(asyncore.dispatcher):
try:
if socket.has_ipv6:
self.create_socket(socket.AF_INET6, socket.SOCK_STREAM)
# Explicitly configure socket to work for both IPv4 and IPv6
self.socket.setsockopt(
socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
else:
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()