Closed PiotrJustyna closed 8 years ago
Piotr,
I suspect the issue you are having is not related to network-simple, but to how stdout buffering is configured for your application. See https://hackage.haskell.org/package/base-4.9.0.0/docs/System-IO.html#g:12
Try enabling line buffering explicitly and see if that improves things.
On Sep 11, 2016 2:24 PM, "Piotr Justyna" notifications@github.com wrote:
First of all, thank you for putting the library together - super useful!
I've been playing with the server code for a while now and for some reason, it doesn't always print to the console when I would expect it to. Sample code:
module Main where import Network.Simple.TCP main :: IO () main = serve (Host "127.0.0.1") "4242" $ (connectionSocket, remoteAddr) -> do putStrLn $ "TCP connection established from " ++ show remoteAddr
The server is running just fine, I can connect both from telnet and from a client written in Network.Simple.TCP. Same happens with the examples, e.g. https://github.com/k0001/network-simple/blob/master/ examples/echo-tcp.hs. Am I missing something?
Environment: Windows 10, Stack
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/k0001/network-simple/issues/24, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAM5psu3gzdJYAB_JtKRv8SGUhloU_7ks5qpDkxgaJpZM4J6Dhb .
Thanks. Let me try that and I'll update the issue with me findings.
Thank you, that was it :smile:
If anybody else gets stuck on this issue, here's a sample piece of code checking and then setting the desired buffering type:
module Main where
import Network.Simple.TCP
import System.IO
main :: IO ()
main = do
bufferingModeBefore <- hGetBuffering stdout
putStrLn $ "Current buffering mode: " ++ (show bufferingModeBefore)
hSetBuffering stdout NoBuffering
bufferingModeAfter <- hGetBuffering stdout
putStrLn $ "Current buffering mode: " ++ (show bufferingModeAfter)
serve (Host "127.0.0.1") "4242" $ \(connectionSocket, remoteAddr) -> do
putStrLn $ "TCP connection established from " ++ show remoteAddr
First of all, thank you for putting the library together - super useful!
I've been playing with the server code for a while now and for some reason, it doesn't always print to the console when I would expect it to. Sample code:
The server is running just fine, I can connect both from telnet and from a client written in
Network.Simple.TCP
. Same happens with the examples, e.g. https://github.com/k0001/network-simple/blob/master/examples/echo-tcp.hs. Am I missing something?Environment: Windows 10, Stack