Skip to content

Instantly share code, notes, and snippets.

@amalloy
Last active April 5, 2016 19:35
Show Gist options
  • Save amalloy/4ce60d93dd82e6aa8dec8e90e4796230 to your computer and use it in GitHub Desktop.
Save amalloy/4ce60d93dd82e6aa8dec8e90e4796230 to your computer and use it in GitHub Desktop.
writeAll :: Socket -> String -> IO ()
writeAll socket s = do
sent <- send socket s
case drop sent s of
"" -> return ()
s -> writeAll socket s
echo :: Socket -> IO ()
echo client = do
input <- recv client 4096
if null input
then close client
else writeAll client input >> echo client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment