MPD: Use AF_INET instead of AF_INET6 if the host does not have IPv6 support

This commit is contained in:
Stein Magnus Jodal 2010-06-30 20:18:22 +02:00
parent 7922795d2f
commit 22f011d57f

View File

@ -32,7 +32,11 @@ class MpdServer(asyncore.dispatcher):
def start(self):
try:
self.create_socket(socket.AF_INET6, socket.SOCK_STREAM)
if socket.has_ipv6:
protocol_family = socket.AF_INET6
else:
protocol_family = socket.AF_INET
self.create_socket(protocol_family, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind((self._format_hostname(settings.SERVER_HOSTNAME),
settings.SERVER_PORT))