[Haskell-cafe] How to design an network client with user program.

Alexander V Vershilov alexander.vershilov at gmail.com
Tue Apr 9 12:09:05 CEST 2013


I have next problem: I have a network client that connects to server,
listens for messages and generate responces. So the control flow can be
represended as:

server -- input -> {generate output} -> output

Output can be generated using default implementation or can overriden by

The main difficulty appeares when I need to add a user program on the top
of this logic,
i.e. from user-side I want to have dsl:smth like

withClient $ do
   x <- send message
   waitFor x
   timeout 5000000
   forever $ sendRandomMessage

i.e. an ability to send messages, waiting for some event (message to come),
waiting for

The question is how to define such logic without a big overhead. I see a
solution using conduit, it's possible to create 3 processes: listener,
user, sender.

                         +----> user ----+
                         |                    |
-input -> listener +----------------->+---- sender ->

and use TQueue or TChan to send messages between them, however there can be
another possible solutions, that uses less resources, or another design.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130409/c3daa0e4/attachment.htm>

More information about the Haskell-Cafe mailing list