import IO import Control.Exception hiding (catch) import Control.Concurrent import Network import System.Posix main = withSocketsDo (installHandler sigPIPE Ignore Nothing >> main') main' = listenOn (PortNumber 9900) >>= acceptConnections acceptConnections sock = do conn@(h,host,port) <- accept sock forkIO $ catch (talk conn `finally` hClose h) (\e -> print e) acceptConnections sock talk conn@(h,_,_) = hPutStrLn h "HTTP/1.0 200 OK\r\nContent-Length: 5\r\n\r\nPong!\r\n" >> hFlush h >> hClose h