on 70fb992 help sign in
streamly/examples/FromFileClient.hs
21 lines 719 B history raw
1-- A TCP client that does the following:
2-- * Reads multiple filenames passed on the command line
3-- * Opens as many concurrent connections to the server
4-- * Sends all the files concurrently to the server
6import System.Environment (getArgs)
8import Streamly
9import qualified Streamly.Prelude as S
10import qualified Streamly.Internal.FileSystem.Handle as IFH
11import qualified Streamly.Internal.Network.Inet.TCP as TCP
13import System.IO (withFile, IOMode(..))
15main :: IO ()
16main =
17 let sendFile file =
18 withFile file ReadMode $ \src ->
19 S.fold (TCP.writeChunks (127, 0, 0, 1) 8090)
20 $ IFH.toChunks src
21 in getArgs >>= S.drain . parallely . S.mapM sendFile . S.fromList