Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Thomas ten Cate authored

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. +2 1  server/Main.hs
3  server/Main.hs
@@ -34,7 +34,7 @@ import Scion (runScion)
34 34 import Prelude hiding ( log )
35 35 import System.Environment (getArgs, getProgName)
36 36 import System.Exit (exitSuccess)
37   -import System.IO (stdin, stdout, hSetBuffering, BufferMode(..))
  37 +import System.IO (stdin, stdout, hSetBuffering, hFlush, BufferMode(..))
38 38 import qualified System.Log.Logger as HL
39 39 import qualified System.Log.Handler.Simple as HL
40 40 import qualified System.Log.Handler.Syslog as HL
@@ -125,6 +125,7 @@ serve (TCPIP auto nr) = do
125 125 else listenOn (PortNumber nr)
126 126 realNr <- liftIO $ socketPort sock
127 127 putStrLn $ "=== Listening on port: " ++ show realNr
  128 + hFlush stdout
128 129 forever $ E.handle (\(e::E.IOException) -> logInfo ("caught :" ++ (show e) ++ "\n\nwaiting for next client")) $ do
129 130 (sock', _addr) <- liftIO $ accept sock
130 131 sock_conn <- CIO.mkSocketConnection sock'

0 comments on commit 646ad45

Please sign in to comment.
Something went wrong with that request. Please try again.