refactor--cleanup rpc
rewrite c to cpp
rewrite c to cpp