Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. module Main where
  2. import Network
  3. import Control.Concurrent
  4. import System.IO
  5.  
  6. main = withSocketsDo $ do
  7. handle <- connectTo "localhost" (PortNumber 8000)
  8. hSetBuffering handle LineBuffering
  9. forkIO $ loopRead handle
  10. loopWrite handle
  11. hClose handle
  12.  
  13. loopWrite handle = do
  14. line <- getLine
  15. hPutStrLn handle line
  16. loopWrite handle
  17.  
  18. loopRead handle = do
  19. line <- hGetLine handle
  20. putStrLn line
  21. loopRead handle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement