Cap'n'proto beginner needs help

cap’n’proto beginner needs help

I need a RPC lib usable both from ocaml and c++, which can use UDP as a transport and encrypting the networked communication.

cap’n’proto seems to fit the bill, even if I havent understood what are « capabilities » in this context :-/ not a good start.
My previous exposure to RPC libs was apache thrift, which is a piece of cake to use. But no UDP, no crypto available.

My project impose me to write the server in C++, the client in OCaml. Callback to client code seems a good feat. to have in case.

I’ve tried exercise 1 of the capnp tutorial, writing Callback.log, without much success I think.
In a separate callback.ml file I wrote:

open Capnp_rpc_lwt

module Api = Echo_api.MakeRPC(Capnp_rpc_lwt)
module Callback = Api.Client.Callback

let log t msg =
  Printf.printf "callback.ml/log: got msg %s\n" msg ;
  let open Callback.Log in
  let request, _ = Capability.Request.create Params.init_pointer in
  Capability.call_for_unit t method_id request

Echo.Callback.local in main.ml trigger a compile error (unbound module Echo.Callback) with my module hierarchy.

Where do I need to put my Callback.log?

Thank for any help.

Sorry; the tutorial wasn’t clear. You can make Callback a submodule in echo.ml to fix the problem.

I’ve made a fix for the README: https://github.com/mirage/capnp-rpc/pull/177

With that said, I’m not sure capnp-rpc is going to work with UDP. It relies on reliable in-order deliver of messages, so you’d need to implement something like TCP on top of UDP to do this. You could still use plain capnp encoding with UDP, though, just not the RPC support (interfaces).