Concurrncy is not working well in Windows

{- In FreeBSD ghc-5.04.2 the simple echo server below works fine. (except for broken pipe. Installing signal handler will do good.) It broadcasts "Welcome!" to all users repeatedly. But in Windows XP, cygwin, ghc-5.04.3. It gets blocked on the accept routine and wakes up for a moment when new connections are requested and then get blocked soon, only printing some lines. Inserting yield in the code didn't help either. Is runtime system of cygwin version something wrong or non-blocking IO bad ? It seems almost impossible to write servers in win32. The server just STOPs without reason ! -} import IO import Monad import Network import Control.Exception (finally) import Control.Concurrent acceptConns sock = do conn@(h,host,port) <- accept sock forkIO $ catch (talk conn `finally` hClose h) print acceptConns sock talk conn@(h,_,_) = hPutStrLn h "Welcome!" >> hFlush h >> talk conn main = withSocketsDo $ do sock <- listenOn $ PortNumber 9900 acceptConns sock
participants (1)
-
Ahn Ki-yung