Name: Anonymous 2011-02-16 17:39
telnet 98.255.132.66 9099
Come join the fun!
Come join the fun!
import Network.Fancy
import Control.Concurrent
import Control.Monad
import Control.Exception
import System.IO
main = do hs <- newMVar []
streamServer serverSpec { address = IPv4 "" 9099 } $ \h r ->
modifyMVar_ hs (return . (h:))
>> f r hs h `finally` modifyMVar_ hs (return . filter (/= h))
sleepForever
f r hs h = do x <- hGetLine h
putStrLn $ show r ++ " > " ++ x
when (x /= "/quit") $ do
withMVar hs $ \hs' -> forM (filter (/= h) hs') $ \h' ->
hPutStrLn h' (show r ++ " > " ++ x) >> hFlush h'
f r hs h