From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id A7DF07EE9C for ; Fri, 25 Nov 2016 09:48:34 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.31,546,1473112800"; d="scan'208";a="246658014" Received: from meleze.ens.fr (HELO [129.199.99.114]) ([129.199.99.114]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 25 Nov 2016 09:48:34 +0100 To: caml-list@inria.fr References: From: Francois BERENGER Message-ID: Date: Fri, 25 Nov 2016 09:48:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Compressing stream in Async.Tcp.Server On 11/24/2016 06:19 PM, Paolo Donadeo wrote: > 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. I have some using-cryptokit compression example in there (function zlib): https://github.com/UnixJunkie/daft/blob/master/src/socket_wrapper.ml > 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/ -- Regards, Francois. "When in doubt, use more types"