Ticket #2703: BigSockFail.hs

File BigSockFail.hs, 0.6 KB (added by sclv, 5 years ago)

Failing case

Line 
1module Main where
2import Control.Monad
3import Control.Concurrent
4import System.IO
5import Control.Exception (handle)
6import System.Posix.Signals
7import Network(listenOn, PortID(..),accept, Socket)
8import System.IO
9
10listenSock :: Socket -> IO ThreadId
11listenSock sk = forkIO . forever $ handle (\e -> print e) $ do
12            (h,_,_) <- accept sk
13            hSetBuffering h NoBuffering
14            forkIO . forever $ hGetLine h >>= putStrLn
15            return ()
16
17main :: IO ()
18main = do
19  installHandler sigPIPE Ignore Nothing
20  sk <- listenOn $ PortNumber 9020
21  listenSock sk
22  forever $ threadDelay 1000000