caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Daniil Baturin <daniil@baturin.org>
To: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Handling concurrent connections with Lwt
Date: Tue, 05 May 2015 02:07:37 +0600	[thread overview]
Message-ID: <5547D189.2070101@baturin.org> (raw)
In-Reply-To: <CALdWJ+xqFZG4apsysuwakm-j=fFGoWPxDoBS+AjK4Wwforc-FA@mail.gmail.com>

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. 
> 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 <daniil@baturin.org
> <mailto:daniil@baturin.org>> 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
>
>




      reply	other threads:[~2015-05-04 20:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-01 12:35 [Caml-list] [TFP'15] call for participation Peter Achten
2015-05-04 16:26 ` [Caml-list] Handling concurrent connections with Lwt Daniil Baturin
2015-05-04 17:33   ` Ivan Gotovchits
2015-05-04 20:07     ` Daniil Baturin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5547D189.2070101@baturin.org \
    --to=daniil@baturin.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).