From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr 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 3571F7FD02 for ; Mon, 4 May 2015 19:33:13 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of ivg@ieee.org) identity=pra; client-ip=209.85.215.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of ivg@ieee.org designates 209.85.215.47 as permitted sender) identity=mailfrom; client-ip=209.85.215.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; 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@mail-la0-f47.google.com) identity=helo; client-ip=209.85.215.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="postmaster@mail-la0-f47.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CKAgAtrEdVmy/XVdFcg19cBYMYsFwGgxSOKDOBVoYFAoEmBzoSAQEBAQEBAREBAQEBAQYLCwkhLoQhAQEDARIRSwsFCwsEBxodAgIiEgEFAQoSBhMSEId1AwkIDaYaPjGLOY4hA4R/AQEBAQYBAQEBAQEcCoYNhSKEOkcEB4JogUUFhTwKkFiGQYEkPYYHhwCFbBIjgRWEMyIxgkUBAQE X-IPAS-Result: A0CKAgAtrEdVmy/XVdFcg19cBYMYsFwGgxSOKDOBVoYFAoEmBzoSAQEBAQEBAREBAQEBAQYLCwkhLoQhAQEDARIRSwsFCwsEBxodAgIiEgEFAQoSBhMSEId1AwkIDaYaPjGLOY4hA4R/AQEBAQYBAQEBAQEcCoYNhSKEOkcEB4JogUUFhTwKkFiGQYEkPYYHhwCFbBIjgRWEMyIxgkUBAQE X-IronPort-AV: E=Sophos;i="5.13,366,1427752800"; d="scan'208";a="138906752" Received: from mail-la0-f47.google.com ([209.85.215.47]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 04 May 2015 19:33:12 +0200 Received: by lagv1 with SMTP id v1so109262346lag.3 for ; Mon, 04 May 2015 10:33:11 -0700 (PDT) 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:date :message-id:subject:from:to:cc:content-type; bh=+yJl8GuixuYUSlic9D76SwXtzMBEhyqvtqBhHgZaJl8=; b=gph3jfoP8BFUZv2/9JuZB7jGt5oH4uMr9F2T7BvdcwcMv/DmJ2BDJLXBPP1h2lVdc2 +q/Og/Qx2S71TouxfB1JFP4Vf33C63RI4p080xah3/mzcqTggkgntFP6khvZJP8dGDXO T+GDajakyA9nWb/jiPE6rfsWFCnv12hpkRFMirzb86aEUu4Q74VBQfub4ZweNgQvNa9h vR48XzSDbDcLaqrznG7DZiBBA3nSXC5+I1Whr1OUxTvUL5kZHcnvI+lPp5QZPD/ZaW0R Af7HDqA2hvLybExzFFQxo+0uhBLdv0H21t2R6nJMmZSX8K1B/JzJjSW9yfmopcFwxPpv 4P5w== X-Gm-Message-State: ALoCoQlHe9oL5U0kO0fPu2YtWktLY+4iBZgfEyEvoqpuELc5W7bDzZYYjQkoH5vacsTquW80ONRD MIME-Version: 1.0 X-Received: by 10.112.219.70 with SMTP id pm6mr20075132lbc.41.1430760791640; Mon, 04 May 2015 10:33:11 -0700 (PDT) Received: by 10.114.18.226 with HTTP; Mon, 4 May 2015 10:33:11 -0700 (PDT) In-Reply-To: <55479DC6.4090404@baturin.org> References: <554372F6.9090703@cs.ru.nl> <55479DC6.4090404@baturin.org> Date: Mon, 4 May 2015 13:33:11 -0400 Message-ID: From: Ivan Gotovchits To: Daniil Baturin Cc: caml-list Content-Type: multipart/alternative; boundary=001a11c3ccd8beaa83051544f478 Subject: Re: [Caml-list] Handling concurrent connections with Lwt --001a11c3ccd8beaa83051544f478 Content-Type: text/plain; charset=UTF-8 My usual approach for such kind of tasks is to have an `Lwt_stream.t` of messages, from all the connections. Then I use `Lwt_stream.fold` to literally fold my state over all messages. 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 --001a11c3ccd8beaa83051544f478 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
My usual approach for such kind of tasks is to have an `Lw= t_stream.t` of messages, from all the connections.=C2=A0
Then I use `Lw= t_stream.fold` to literally fold my state over all messages.=C2=A0

On Mon, May 4,= 2015 at 12:26 PM, Daniil Baturin <daniil@baturin.org> wrot= e:
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<= br> 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.=C2=A0 Subscription management and archives:
ht= tps://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
<= br>
--001a11c3ccd8beaa83051544f478--