@@ -5,11 +5,12 @@
55-- * lines from concurrent connections are merged into a single srteam
66-- * writes the line stream to an output file
77
8+import Control.Monad.IO.Class (liftIO)
9+import Network.Socket (close)
810import System.Environment (getArgs)
911
1012import Streamly
1113import Streamly.Data.String
12−import Streamly.Internal.Network.Socket (useSocket)
1314import qualified Streamly.FileSystem.Handle as FH
1415import qualified Streamly.Memory.Array as A
1516import qualified Streamly.Network.Socket as NS
@@ -25,11 +26,12 @@ main = do
2526 (\src -> S.fold (FH.write src)
2627 $ encodeChar8Unchecked
2728 $ S.concatUnfold A.read
28− $ S.concatMapWith parallel (flip useSocket recv)
29+ $ S.concatMapWith parallel use
2930 $ S.unfold NS.listenOnPort 8090)
3031
3132 where
3233
34+ use sk = S.finally (liftIO $ close sk) (recv sk)
3335 recv =
3436 S.splitWithSuffix (== '\n') A.write
3537 . decodeChar8