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 5458D7EE9C for ; Fri, 25 Nov 2016 03:40:22 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=yminsky@janestreet.com; spf=Pass smtp.mailfrom=yminsky@janestreet.com; spf=None smtp.helo=postmaster@mxout3.mail.janestreet.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of yminsky@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of yminsky@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mxout3.mail.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="postmaster@mxout3.mail.janestreet.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AXdQqwBWLcsA4BK+5bbg4BkL+aSfV8LGtZVwlr6E/?= =?us-ascii?q?grcLSJyIuqrYZhWEt8tkgFKBZ4jH8fUM07OQ6PG7HzdYqsva+DBaKdoXCE9D0Z?= =?us-ascii?q?1X1yUbQ+e7SmTDZMbwaCI7GMkQHHRExFqcdXZvJcDlelfJqWez5zNBUj/2NA5y?= =?us-ascii?q?O/inUtWK15f//6mI9pbSewRFgiamKfM3dU3u7FaZis5DuYJlLqF55hzPq3dFfK?= =?us-ascii?q?wC3SVkIlSakxv7zsi19Z9ntS9XvqRy2dRHVPDLdr4/S/R9DTI9MHF9sNzutB/Y?= =?us-ascii?q?Thqn5HIaX34KiBdFH07O6xSsDcS5iTfzqucogHrSBsbxV71hHG36t6o=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BpAgCwozdYfeXIaSZdGwEBAQMBAQEJA?= =?us-ascii?q?QEBFgEBAQMBAQEJAQEBgw0BAQEBAXeBAgeBNKMih3KPCiqFdwKBcQdCEQEBAQE?= =?us-ascii?q?BAQEBAQEBEgEBCRYJTYIzBAEVAQSCFwEBBBIRBBkBATcBDwsLAwoCAiYCAiEBE?= =?us-ascii?q?gEFARwGExsHiDEDFwMLnXKBMj8yimlngWw9gwwBAQWEIw2ECgEBAQEBAQEDAQE?= =?us-ascii?q?BAQEBAQEBFgMFEnmFM4RbgkgcgU+DGoJdj3KKMjWGSIZog1aQMolAhDGCSBMeg?= =?us-ascii?q?RM0gRYTDCERAoMVgiZUhmiBTwEBAQ?= X-IPAS-Result: =?us-ascii?q?A0BpAgCwozdYfeXIaSZdGwEBAQMBAQEJAQEBFgEBAQMBAQE?= =?us-ascii?q?JAQEBgw0BAQEBAXeBAgeBNKMih3KPCiqFdwKBcQdCEQEBAQEBAQEBAQEBEgEBC?= =?us-ascii?q?RYJTYIzBAEVAQSCFwEBBBIRBBkBATcBDwsLAwoCAiYCAiEBEgEFARwGExsHiDE?= =?us-ascii?q?DFwMLnXKBMj8yimlngWw9gwwBAQWEIw2ECgEBAQEBAQEDAQEBAQEBAQEBFgMFE?= =?us-ascii?q?nmFM4RbgkgcgU+DGoJdj3KKMjWGSIZog1aQMolAhDGCSBMegRM0gRYTDCERAoM?= =?us-ascii?q?VgiZUhmiBTwEBAQ?= X-IronPort-AV: E=Sophos;i="5.31,692,1473112800"; d="scan'208";a="246624985" Received: from mxout3.mail.janestreet.com ([38.105.200.229]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Nov 2016 03:39:41 +0100 Received: from tot-qpr-mailcore1.delacy.com ([172.27.56.68] helo=tot-qpr-mailcore1) by mxout3.mail.janestreet.com with esmtps (UNKNOWN:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.82) (envelope-from ) id 1cA6QN-0003ru-GL for caml-list@inria.fr; Thu, 24 Nov 2016 21:39:39 -0500 X-JS-Flow: external X-JS-Scanner-attachment: (ok) No attachments Received: by tot-qpr-mailcore1 with JS-mailcore (0.1) (envelope-from ) id BYN6Rr-AAAD6R-Od; 2016-11-24 21:39:39.464476-05:00 Received: from mail-ua0-f198.google.com ([209.85.217.198]) by mxgoog1.mail.janestreet.com with esmtps (UNKNOWN:AES128-GCM-SHA256:128) (Exim 4.72) (envelope-from ) id 1cA6QN-0001oN-C1 for caml-list@inria.fr; Thu, 24 Nov 2016 21:39:39 -0500 Received: by mail-ua0-f198.google.com with SMTP id b35so61781184uaa.1 for ; Thu, 24 Nov 2016 18:39:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=v/L3MD8EfLCTFngDZakxsEOp/QFgZ2J5REMspbsk0+U=; b=iWPmTeEdmxe1ogEwDJyYF5kezMWBVB5ymyVZWjbp3lK5wNAXvHZbCbg0QUPCJWA6pb GEtNCuSlqyX/UWGFx0HUF3aE9AvoxBk7m9vhmp4muw0n/RtEQ6m3S/hxH7TNuzO+g4E8 O+wMudk7XpRBulR3EXX+ylp9A8jrUhwCssed0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=v/L3MD8EfLCTFngDZakxsEOp/QFgZ2J5REMspbsk0+U=; b=m/EQzrJdMR31/Lm8Q1wxV7mIUFLX7yqMOW9HvnMldvu+Bv6m8icKzmN3X2mc2x7LCk vDFhk4wq/pi2J4MjZhClcCXPMAH0CJNFWqpq8I98m9nTfaP72LoE1KVgRFlCUdWCtqf7 9edBXLzrFWeHbcoNhnpIqXIljz5HtpGOvMnGQSq6z+qE/vePs5ymnZn9SeAUy11rmSdo wlPcV2O2n3ayoNnxn05nQQe37INAdCG+OTimZgOKWA/8Qhj2sNNz5UGntouziRSVGFWt 8JA2I+E4afHA0o0lo+o89hzafH5qGmndjjdoCDET8Cokv1dTPABgeBJExyczwMClFyV4 EyJw== X-Gm-Message-State: AKaTC01ER14ReD0lmB/Xsxv96Tu/PL3gVLKi95fnx7+XYuzPAWt2GAKf0mmfNq7uWY7fpllMxlEqi/c5lCfWITUPIP84liKJxcD0OCxffzw8XJvyknDlHXTPJ5rktcv0zCc/NfOXTEKJLhlrS/M2 X-Received: by 10.31.216.134 with SMTP id p128mr2189789vkg.147.1480041579032; Thu, 24 Nov 2016 18:39:39 -0800 (PST) X-Received: by 10.31.216.134 with SMTP id p128mr2189781vkg.147.1480041578797; Thu, 24 Nov 2016 18:39:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.202.71 with HTTP; Thu, 24 Nov 2016 18:39:18 -0800 (PST) In-Reply-To: References: From:Yaron Minsky Date: Thu, 24 Nov 2016 21:39:18 -0500 Message-ID: To:Paolo Donadeo Cc:OCaml List , Owen Traeholt , Jeremie Dimino Content-Type: text/plain; charset=UTF-8 X-JS-Processed-by: mailcore Subject: Re: [Caml-list] Compressing stream in Async.Tcp.Server Looping in some folk who work on Async-RPC. This is a good question. I think there isn't an especially nice solution for this, but one can write an alternate transport satisfying this interface: https://github.com/janestreet/async_rpc_kernel/blob/master/src/transport_intf.ml that does the compression, which should be enough. But this is not nicely pre-packaged functionality. It would be nice to have that, and PRs are certainly welcome... y On Thu, Nov 24, 2016 at 12: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. > > 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