On 01/14/2012 11:42 AM, Joey Adams wrote:
On Sat, Jan 14, 2012 at 1:29 AM, Bardur Arantsson<s...@scientician.net>  wrote:
So, the API becomes something like:

   runSocketServer :: ((Chan a, Chan b) ->  IO ()) ->  ... ->  IO ()

where the first parameter contains the "client logic" and "A" is the type of
the messages from the client and "B" is the type of the messages which are
sent back to the client.

Thanks, that's a good idea.  Even if I only plan to receive in one
thread, placing the messages in a Chan or TChan helps separate my
application thread from the complexities of connection management.


Unless TCP is an absolute requirement, something like 0MQ[1,2] may be worth investigating.

It handles all the nasty details and you get a simple message-based interface with lots of nice things like pub-sub, request-reply, etc. etc.

[1] http://hackage.haskell.org/package/zeromq-haskell-0.8.2
[2] http://www.zeromq.org/



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to