on master help sign in
do not use useSocket in server example
1a60915Harendra Kumar
examples/FileSinkServer.hs+4−2
@@ -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
7
7
8+import Control.Monad.IO.Class (liftIO)
9+import Network.Socket (close)
8import System.Environment (getArgs)
10import System.Environment (getArgs)
9
11
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)
30
31
31 where
32 where
32
33
34+ use sk = S.finally (liftIO $ close sk) (recv sk)
33 recv =
35 recv =
34 S.splitWithSuffix (== '\n') A.write
36 S.splitWithSuffix (== '\n') A.write
35 . decodeChar8
37 . decodeChar8
streamly.cabal+1
@@ -915,6 +915,7 @@ executable FileSinkServer
915 build-Depends:
915 build-Depends:
916 streamly
916 streamly
917 , base >= 4.8 && < 5
917 , base >= 4.8 && < 5
918+ , network >= 2.6 && < 4
918 else
919 else
919 buildable: False
920 buildable: False
920
921