@@ -5,11 +5,12 @@
5-- * lines from concurrent connections are merged into a single srteam
5-- * lines from concurrent connections are merged into a single srteam
6-- * writes the line stream to an output file
6-- * writes the line stream to an output file
8+import Control.Monad.IO.Class (liftIO)
9+import Network.Socket (close)
8import System.Environment (getArgs)
10import System.Environment (getArgs)
10import Streamly
12import Streamly
11import Streamly.Data.String
13import Streamly.Data.String
12−import Streamly.Internal.Network.Socket (useSocket)
13import qualified Streamly.FileSystem.Handle as FH
14import qualified Streamly.FileSystem.Handle as FH
14import qualified Streamly.Memory.Array as A
15import qualified Streamly.Memory.Array as A
15import qualified Streamly.Network.Socket as NS
16import qualified Streamly.Network.Socket as NS
@@ -25,11 +26,12 @@ main = do
25 (\src -> S.fold (FH.write src)
26 (\src -> S.fold (FH.write src)
26 $ encodeChar8Unchecked
27 $ encodeChar8Unchecked
27 $ S.concatUnfold A.read
28 $ S.concatUnfold A.read
28− $ S.concatMapWith parallel (flip useSocket recv)
29+ $ S.concatMapWith parallel use
29 $ S.unfold NS.listenOnPort 8090)
30 $ S.unfold NS.listenOnPort 8090)
34+ use sk = S.finally (liftIO $ close sk) (recv sk)
34 S.splitWithSuffix (== '\n') A.write
36 S.splitWithSuffix (== '\n') A.write
35 . decodeChar8
37 . decodeChar8