diff -ruN a/memcache.py b/memcache.py --- a/memcache.py 2011-11-28 02:17:32.000000000 +0100 +++ b/memcache.py 2013-04-26 11:18:47.765452711 +0200 @@ -1042,6 +1042,9 @@ # parse the connection string m = re.match(r'^(?Punix):(?P.*)$', host) if not m: + m = re.match(r'^(?Pinet6):' + r'\[(?P[^\[\]]+)\](:(?P[0-9]+))?$', host) + if not m: m = re.match(r'^(?Pinet):' r'(?P[^:]+)(:(?P[0-9]+))?$', host) if not m: m = re.match(r'^(?P[^:]+)(:(?P[0-9]+))?$', host) @@ -1052,10 +1055,15 @@ if hostData.get('proto') == 'unix': self.family = socket.AF_UNIX self.address = hostData['path'] + elif hostData.get('proto') == 'inet6': + self.family = socket.AF_INET6 + self.ip = hostData['host'] + self.port = int(hostData.get('port') or 11211) + self.address = ( self.ip, self.port ) else: self.family = socket.AF_INET self.ip = hostData['host'] - self.port = int(hostData.get('port', 11211)) + self.port = int(hostData.get('port') or 11211) self.address = ( self.ip, self.port ) self.deaduntil = 0 @@ -1158,6 +1166,8 @@ if self.family == socket.AF_INET: return "inet:%s:%d%s" % (self.address[0], self.address[1], d) + elif self.family == socket.AF_INET6: + return "inet6:[%s]:%d%s" % (self.address[0], self.address[1], d) else: return "unix:%s%s" % (self.address, d)