def METHOD_NAME(conn, rpc_key):
    """Handle a single connection that has just been accept'd()."""
    def send(data):
        conn.sendall(data)
        return len(data)
    magic = struct.unpack("<i", base.recvall(conn, 4))[0]
    if magic != base.RPC_MAGIC:
        conn.close()
        return
    keylen = struct.unpack("<i", base.recvall(conn, 4))[0]
    key = py_str(base.recvall(conn, keylen))
    arr = key.split()
    expect_header = "client:"
    server_key = "server:" + rpc_key
    if arr[0] != expect_header:
        conn.sendall(struct.pack("<i", base.RPC_CODE_MISMATCH))
        _LOG.warning("mismatch key from %s", addr)
        return
    conn.sendall(struct.pack("<i", base.RPC_CODE_SUCCESS))
    conn.sendall(struct.pack("<i", len(server_key)))
    conn.sendall(server_key.encode("utf-8"))
    server = _ffi_api.CreateEventDrivenServer(send, "microtvm-rpc-debugger", key)
    def _readall(n):
        buf = bytearray()
        while len(buf) < n:
            x = conn.recv(n - len(buf))
            if not x:
                raise ConnectionClosedError()
            buf = buf + x
        return buf
    while True:
        packet_length_bytes = _readall(8)
        packet_length = struct.unpack("<q", packet_length_bytes)[0]
        if not packet_length:
            break
        status = server(packet_length_bytes, 3)
        if status == 0:
            break
        packet_body = _readall(packet_length)
        status = server(packet_body, 3)