Hi all, I'm writing a simple client/server application using Async.Rpc. The skeletons of the client and server is essentially derived from the examples available on line.

Since the messages are highly compressible, I would like to use ZLib (e.g. Cryptokit) but I can't figure out how.

Any ideas?

CLIENT:
    Tcp.with_connection
      (Tcp.to_host_and_port host port)
      ~timeout:(sec 1.)
      (fun _ r w ->
        (* COMPRESSION HERE, HOW? *)
        Rpc.Connection.create r w ~connection_state:Pervasives.ignore
        >>= function
        | Error exn -> raise exn
        | Ok conn   -> begin
            let msg = {
              Rpc_protocol.scada_uuid = conf.Config_manager.scada_uuid;
              measures;
            } in
            Rpc.Rpc.dispatch Rpc_protocol.export_data_rpc conn msg >>= function
            | Ok response -> return response
            | Error e -> begin
                error ~tags "SERVER SIDE EXCEPTION";
                error ~tags "    %s" (Error.to_string_hum e);
                return false
              end
          end
      )


SERVER:
  Tcp.Server.create
    ~on_handler_error:(`Call (fun _ exn -> Log.Global.sexp (Exn.sexp_of_t exn)))
    (Tcp.on_port port)
    (fun _addr r w ->
      (* COMPRESSION HERE, HOW? *)
      Rpc.Connection.server_with_close r w
        ~connection_state:(fun c ->
          {
            db_thread = db_thread;
          }
        )
        ~on_handshake_error:(
          `Call (fun exn -> Log.Global.sexp (Exn.sexp_of_t exn); return ()))
        ~implementations)


--
Paolo