gameServer/hedgewars-server.hs
branch0.9.14
changeset 4247 b9fe93f187c4
parent 4242 5e3c5fe2cb14
child 4295 1f5604cd99be
equal deleted inserted replaced
4245:3084dc7b4624 4247:b9fe93f187c4
     2 
     2 
     3 module Main where
     3 module Main where
     4 
     4 
     5 import Network.Socket
     5 import Network.Socket
     6 import qualified Network
     6 import qualified Network
       
     7 import Network.BSD
     7 import Control.Concurrent.STM
     8 import Control.Concurrent.STM
     8 import Control.Concurrent.Chan
     9 import Control.Concurrent.Chan
     9 #if defined(NEW_EXCEPTIONS)
    10 #if defined(NEW_EXCEPTIONS)
    10 import qualified Control.OldException as Exception
    11 import qualified Control.OldException as Exception
    11 #else
    12 #else
    49     let serverInfo = serverInfo'{dbHost = dbHost', dbLogin = dbLogin', dbPassword = dbPassword'}
    50     let serverInfo = serverInfo'{dbHost = dbHost', dbLogin = dbLogin', dbPassword = dbPassword'}
    50 #else
    51 #else
    51     let serverInfo = serverInfo'
    52     let serverInfo = serverInfo'
    52 #endif
    53 #endif
    53 
    54 
       
    55 
       
    56     proto <- getProtocolNumber "tcp"
    54     Exception.bracket
    57     Exception.bracket
    55         (Network.listenOn $ Network.PortNumber $ listenPort serverInfo)
    58         (socket AF_INET Stream proto)
    56         sClose
    59         sClose
    57         (startServer serverInfo)
    60         (\sock -> do
       
    61             setSocketOption sock ReuseAddr 1
       
    62             bindSocket sock (SockAddrInet (listenPort serverInfo) iNADDR_ANY)
       
    63             listen sock maxListenQueue
       
    64             startServer serverInfo sock
       
    65         )