Skip to content


Subversion checkout URL

You can clone with
Download ZIP
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...
commit 646ad45f3bf869d363fc9bbf9a10dfbb9086aad9 1 parent 3d2d972
@ttencate authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  server/Main.hs
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'
Please sign in to comment.
Something went wrong with that request. Please try again.