Browse files

Flush stdout before starting to listen on a port.

Not flushing caused the client never to receive the port number.
  • Loading branch information...
1 parent 3d2d972 commit 646ad45f3bf869d363fc9bbf9a10dfbb9086aad9 @ttencate committed Jun 23, 2009
Showing with 2 additions and 1 deletion.
  1. +2 −1 server/Main.hs
View
3 server/Main.hs
@@ -34,7 +34,7 @@ import Scion (runScion)
import Prelude hiding ( log )
import System.Environment (getArgs, getProgName)
import System.Exit (exitSuccess)
-import System.IO (stdin, stdout, hSetBuffering, BufferMode(..))
+import System.IO (stdin, stdout, hSetBuffering, hFlush, BufferMode(..))
import qualified System.Log.Logger as HL
import qualified System.Log.Handler.Simple as HL
import qualified System.Log.Handler.Syslog as HL
@@ -125,6 +125,7 @@ serve (TCPIP auto nr) = do
else listenOn (PortNumber nr)
realNr <- liftIO $ socketPort sock
putStrLn $ "=== Listening on port: " ++ show realNr
+ hFlush stdout
forever $ E.handle (\(e::E.IOException) -> logInfo ("caught :" ++ (show e) ++ "\n\nwaiting for next client")) $ do
(sock', _addr) <- liftIO $ accept sock
sock_conn <- CIO.mkSocketConnection sock'

0 comments on commit 646ad45

Please sign in to comment.