Apply rev b9fe93f187c4 to server rewrite too server_refactor
authorunc0rr
Wed, 26 Jan 2011 22:06:27 +0300
branchserver_refactor
changeset 4593 39d07170085b
parent 4591 c91364bf6a69
child 4595 cd4433b44920
Apply rev b9fe93f187c4 to server rewrite too
gameServer/hedgewars-server.hs
--- a/gameServer/hedgewars-server.hs	Wed Jan 26 22:04:18 2011 +0300
+++ b/gameServer/hedgewars-server.hs	Wed Jan 26 22:06:27 2011 +0300
@@ -2,7 +2,8 @@
 
 module Main where
 
-import Network
+import Network.Socket
+import Network.BSD
 import Control.Concurrent.STM
 import Control.Concurrent.Chan
 import qualified Control.Exception as Exception
@@ -46,7 +47,14 @@
     let serverInfo = serverInfo'
 #endif
 
+
+    proto <- getProtocolNumber "tcp"
     Exception.bracket
-        (Network.listenOn $ Network.PortNumber $ listenPort serverInfo)
+        (socket AF_INET Stream proto)
         sClose
-        (startServer serverInfo)
+        (\sock -> do
+            setSocketOption sock ReuseAddr 1
+            bindSocket sock (SockAddrInet (listenPort serverInfo) iNADDR_ANY)
+            listen sock maxListenQueue
+            startServer serverInfo sock
+        )