Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] Compressing stream in Async.Tcp.Server
@ 2016-11-24 17:19 Paolo Donadeo
  2016-11-25  2:39 ` Yaron Minsky
  2016-11-25  8:48 ` Francois BERENGER
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Donadeo @ 2016-11-24 17:19 UTC (permalink / raw)
  To: OCaml List

[-- Attachment #1: Type: text/plain, Size: 1639 bytes --]

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*

[-- Attachment #2: Type: text/html, Size: 4371 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-25  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-24 17:19 [Caml-list] Compressing stream in Async.Tcp.Server Paolo Donadeo
2016-11-25  2:39 ` Yaron Minsky
2016-11-25  8:48 ` Francois BERENGER

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox