Tutorial for server programming in concurrent Haskell

I've recently started a small tutorial for server programming in concurrent Haskell. http://kyagrd.dyndns.org/wiki/HaskellServerProgramming For newbies in Haskell and/or server programming, there should be an interoductory tutorial with concrete and simple examples before Simon Marlow's papers about web server implementation in Haskell. This tutorial consists of two famous examples, Echo and Chat, with the source code and makefile to be downloaded, compliled and tested right away. I hope this could be some helpt to those who want to start server programming in Haskell. Server programming in modern fucntional language with concurrency support is a real pleasure! You should also try Erlang if you havnt' tried yet.

Ahn Ki-yung writes:
I've recently started a small tutorial for server programming in concurrent Haskell.
Very cool. Network programming is one of my interests, too, and unfortunately it is still very difficult to get started with that in Haskell. Thanks for putting all that effort into the page. It's very nice. Two comments: | acceptConnections sock = do | putStrLn "trying to accept" -- debug msg | conn@(h,host,port) <- accept sock | print conn -- debug msg | forkIO $ catch (talk conn `finally` hClose h) (\e -> print e) | acceptConnections sock | | talk conn@(h,_,_) = hGetLine h >>= hPutStrLn h >> hFlush h >> talk conn Note that the 'accept' call may throw an exception, too. If it does, it will take the whole server down because all IO threads terminate when 'main' terminates. This is probably not what you want. Also, I'd avoid using hGetLine when reading from a network socket, because the function doesn't implement any sort of timeout or maximum line length. Hence, an attacker can overflow your heap (and potentially crash the program) by sending you an appropriately long input line. Hope this helps. Peter
participants (2)
-
Ahn Ki-yung
-
Peter Simons