'Read a domain name from the packet.'

def readName(self):

    result = ''
    off = self.offset
    next = (-1)
    first = off
    while True:
        length = ord(self.data[off])
        off += 1
        if (length == 0):
            break
        t = (length & 192)
        if (t == 0):
            result = ''.join((result, (self.readUTF(off, length) + '.')))
            off += length
        elif (t == 192):
            if (next < 0):
                next = (off + 1)
            off = (((length & 63) << 8) | ord(self.data[off]))
            if (off >= first):
                text = ('Bad    domain    name    (circular)    at    ' + str(off))
                raise Exception(text)
            first = off
        else:
            raise Exception(('Bad    domain    name    at    ' + str(off)))
    if (next >= 0):
        self.offset = next
    else:
        self.offset = off
    return result
