Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Telnet chat server

Name: Anonymous 2011-02-16 17:39

telnet 98.255.132.66 9099

Come join the fun!

Name: Anonymous 2011-11-28 7:18

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

Server at 50.56.35.147:9099, I'll leave it up like forever.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List