'Write a domain name to the packet.'

def writeName(self, name):

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