Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import System.Environment (getArgs)
- import Network
- import System.IO
- import Control.Concurrent (forkIO)
- import Control.Monad (unless)
- import Data.Map
- process :: Handle -> IO ()
- process handle = do
- eof <- hIsEOF handle
- if eof
- then putStrLn "Interrupted"
- else (hGetLine handle >>= putStrLn >> process handle)
- handler sock = do
- (handle, _, _) <- accept sock
- hSetBuffering handle LineBuffering
- forkIO $ process handle
- handler sock
- main = withSocketsDo $ do
- sock <- listenOn (PortNumber 11111)
- handler sock
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement