'Writes a domain name to the packet'

def writeName(self, name):

    try:
        index = self.names[name]
    except KeyError:
        self.names[name] = self.size
        parts = name.split('.')
        if (parts[(-1)] == ''):
            parts = parts[:(-1)]
        for part in parts:
            self.writeUTF(part)
        self.writeByte(0)
        return
    self.writeByte(((index >> 8) | 192))
    self.writeByte(index)
