--- a/gameServer/NetRoutines.hs Sat Apr 11 17:37:43 2015 +0300
+++ b/gameServer/NetRoutines.hs Wed Apr 29 17:17:40 2015 +0300
@@ -29,18 +29,18 @@
import qualified Data.ByteString.Char8 as B
import qualified Control.Exception as E
import System.Entropy
+import Data.Either
-----------------------------
import CoreTypes
import Utils
acceptLoop :: Socket -> Chan CoreMessage -> IO ()
-acceptLoop servSock chan = E.bracket openHandle closeHandle f
+acceptLoop servSock chan = E.bracket openHandle closeHandle (forever . f)
where
- f ch = forever $
- do
- (sock, sockAddr) <- Network.Socket.accept servSock
-
+ f ch = E.try (Network.Socket.accept servSock) >>= \v -> case v of
+ Left (e :: E.IOException) -> return ()
+ Right (sock, sockAddr) -> do
clientHost <- sockAddr2String sockAddr
currentTime <- getCurrentTime