addrbytes = [int(part) for part in addr.split('.')]
portshort = int(port)
buf = struct.pack('!4Bh', addrbytes[0], addrbytes[1], addrbytes[2],
    addrbytes[3], portshort)
is there a Python Equivalent to Memcpy