'Reads a domain name from the packet'

def readName(self):

    result = ''
    off = self.offset
    next = (-1)
    first = off
    while 1:
        try:
            len = ord(self.data[off])
            off += 1
            if (len == 0):
                break
            t = (len & 192)
            if (t == 0):
                result = ''.join((result, (self.readUTF(off, len) + '.')))
                off += len
            elif (t == 192):
                if (next < 0):
                    next = (off + 1)
                off = (((len & 63) << 8) | ord(self.data[off]))
                if (off >= first):
                    raise BadDomainNameCircular(off)
                first = off
            else:
                raise BadDomainName(off)
        except IndexError:
            raise MalformedPacketException()
    if (next >= 0):
        self.offset = next
    else:
        self.offset = off
    return result
