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 EBC8E7FD02 for ; Mon, 4 May 2015 22:07:39 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of daniil@baturin.org) identity=pra; client-ip=46.253.202.162; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="daniil@baturin.org"; x-sender="daniil@baturin.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of daniil@baturin.org designates 46.253.202.162 as permitted sender) identity=mailfrom; client-ip=46.253.202.162; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="daniil@baturin.org"; x-sender="daniil@baturin.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@smtp.enfan.org designates 46.253.202.162 as permitted sender) identity=helo; client-ip=46.253.202.162; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="daniil@baturin.org"; x-sender="postmaster@smtp.enfan.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CzBADK0EdV/6LK/S5cg18SSoMds3uQMYYBAgICCIFmEAEBAQEBAQGBCoQhAQEEIwRHChELGAICBQQPAQIIAwICCQMCAQIBMwERBg0GAgEBDogFAxUJsweOLwOFMAEBAQEdgSGKGIQ6GDowgjiBRQEEhTwKhjqKHodlPYVXMIcAhzYjg35lgkUBAQE X-IPAS-Result: A0CzBADK0EdV/6LK/S5cg18SSoMds3uQMYYBAgICCIFmEAEBAQEBAQGBCoQhAQEEIwRHChELGAICBQQPAQIIAwICCQMCAQIBMwERBg0GAgEBDogFAxUJsweOLwOFMAEBAQEdgSGKGIQ6GDowgjiBRQEEhTwKhjqKHodlPYVXMIcAhzYjg35lgkUBAQE X-IronPort-AV: E=Sophos;i="5.13,367,1427752800"; d="scan'208";a="138919771" Received: from srv-se.enfan.org (HELO smtp.enfan.org) ([46.253.202.162]) by mail2-smtp-roc.national.inria.fr with ESMTP; 04 May 2015 22:07:39 +0200 Received: from eirin.enfan.tld (static-user-46-236-133-210.tomtelnet.ru [46.236.133.210]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by smtp.enfan.org (Postfix) with ESMTPSA id 8BE4612773C for ; Tue, 5 May 2015 02:07:38 +0600 (NOVT) Message-ID: <5547D189.2070101@baturin.org> Date: Tue, 05 May 2015 02:07:37 +0600 From: Daniil Baturin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: caml-list References: <554372F6.9090703@cs.ru.nl> <55479DC6.4090404@baturin.org> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Handling concurrent connections with Lwt Never ending fold sounds attractive. How do you construct the stream of messages? If I use Lwt_stream.from, the unit -> 'a option Lwt.t function it uses should have access to a list of descriptors to read from, which needs to be updated when new connections come in. How to do this without mutable state accessible to all threads? On 05/04/2015 11:33 PM, Ivan Gotovchits wrote: > My usual approach for such kind of tasks is to have an `Lwt_stream.t` > of messages, from all the connections.=20 > Then I use `Lwt_stream.fold` to literally fold my state over all > messages.=20 > > On Mon, May 4, 2015 at 12:26 PM, Daniil Baturin > wrote: > > Hi all, > > I'm trying to figure out how to handle concurrent connections with > Lwt, > and I'm quite confused. > > Suppose I'm writing an IRC server (actually I'm not, but connection > handling model will be similar). > I need to accept connections, read from descriptors, and update > some state. > > So far I've only found examples of handling HTTP-style requests (reply > and close). > > What is the proper way to do this in Lwt? Are there any projects > or code > examples I can learn from? > > Thanks, > Daniil > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >