X-Git-Url: http://git.kaliko.me/?p=python-musicpd.git;a=blobdiff_plain;f=mpd.py;h=384f856f522d44214c444179c2f5ba586d48e4f2;hp=8b70f4aa955ffcfcf2bda81f85c642879238e76b;hb=74eff57815a3308a1fafd14c1ebbcdb8714bec75;hpb=492dab03155b00536deebeb2916a859de62e52f7 diff --git a/mpd.py b/mpd.py index 8b70f4a..384f856 100644 --- a/mpd.py +++ b/mpd.py @@ -291,9 +291,13 @@ class MPDClient(object): if self._sock: raise ConnectionError("Already connected") msg = "getaddrinfo returns an empty list" + try: + flags = socket.AI_ADDRCONFIG + except AttributeError: + flags = 0 for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM, socket.IPPROTO_TCP, - socket.AI_ADDRCONFIG): + flags): af, socktype, proto, canonname, sa = res try: self._sock = socket.socket(af, socktype, proto) @@ -310,7 +314,7 @@ class MPDClient(object): self._wfile = self._sock.makefile("wb") try: self._hello() - except (socket.error, MPDError): + except: self.disconnect() raise