gameServer/NetRoutines.hs
changeset 2296 19f2f76dc346
parent 2245 c011aecc95e5
child 2348 b39d826e1ccd
equal deleted inserted replaced
2295:2fff3e4ce52f 2296:19f2f76dc346
     1 {-# LANGUAGE PatternSignatures #-}
     1 {-# LANGUAGE CPP, PatternSignatures #-}
     2 module NetRoutines where
     2 module NetRoutines where
     3 
     3 
     4 import Network
     4 import Network
     5 import Network.Socket
     5 import Network.Socket
     6 import System.IO
     6 import System.IO
     7 import Control.Concurrent
     7 import Control.Concurrent
     8 import Control.Concurrent.Chan
     8 import Control.Concurrent.Chan
     9 import Control.Concurrent.STM
     9 import Control.Concurrent.STM
    10 import Control.Exception
    10 #if defined(NEW_EXCEPTIONS)
       
    11 import qualified Control.OldException as Exception
       
    12 #else
       
    13 import qualified Control.Exception as Exception
       
    14 #endif
    11 import Data.Time
    15 import Data.Time
    12 -----------------------------
    16 -----------------------------
    13 import CoreTypes
    17 import CoreTypes
    14 import ClientIO
    18 import ClientIO
    15 import Utils
    19 import Utils
    16 
    20 
    17 acceptLoop :: Socket -> Chan CoreMessage -> Int -> IO ()
    21 acceptLoop :: Socket -> Chan CoreMessage -> Int -> IO ()
    18 acceptLoop servSock coreChan clientCounter = do
    22 acceptLoop servSock coreChan clientCounter = do
    19 	Control.Exception.handle
    23 	Exception.handle
    20 		(\(_ :: Exception) -> putStrLn "exception on connect") $
    24 		(\(_ :: Exception.Exception) -> putStrLn "exception on connect") $
    21 		do
    25 		do
    22 		(socket, sockAddr) <- Network.Socket.accept servSock
    26 		(socket, sockAddr) <- Network.Socket.accept servSock
    23 
    27 
    24 		cHandle <- socketToHandle socket ReadWriteMode
    28 		cHandle <- socketToHandle socket ReadWriteMode
    25 		hSetBuffering cHandle LineBuffering
    29 		hSetBuffering cHandle LineBuffering