Make server listen on ipv4 interface only 0.9.14
authorunc0rr
Fri, 12 Nov 2010 20:42:36 +0300
branch0.9.14
changeset 4247 b9fe93f187c4
parent 4245 3084dc7b4624
child 4249 f6d0b8445cac
Make server listen on ipv4 interface only
gameServer/hedgewars-server.hs
--- a/gameServer/hedgewars-server.hs	Fri Nov 12 09:49:46 2010 +0100
+++ b/gameServer/hedgewars-server.hs	Fri Nov 12 20:42:36 2010 +0300
@@ -4,6 +4,7 @@
 
 import Network.Socket
 import qualified Network
+import Network.BSD
 import Control.Concurrent.STM
 import Control.Concurrent.Chan
 #if defined(NEW_EXCEPTIONS)
@@ -51,7 +52,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
+        )