Created
April 1, 2015 00:15
-
-
Save junjihashimoto/42f6519e9e63f7d66347 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Network | |
| import System.IO | |
| import Control.Monad | |
| import Control.Concurrent | |
| main :: IO () | |
| main = withSocketsDo $ do | |
| val <- getContents | |
| sock <- listenOn $ PortNumber 8080 | |
| forever $ do | |
| (handle, _host, _port) <- accept sock | |
| forkFinally (talk handle val) (\_ -> hClose handle) | |
| where | |
| talk h val = do | |
| hPutStr h val | |
| v <- hGetContents h | |
| putStr v | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment