on 41753e4 help sign in
streamly/examples/FromFileClient.hs
20 lines 678 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.FileSystem.Handle as FH
11import qualified Streamly.Network.Client as Client
13import System.IO (withFile, IOMode(..))
15main :: IO ()
16main =
17 let sendFile file =
18 withFile file ReadMode $ \src ->
19 Client.writeArrays (127, 0, 0, 1) 8090 $ FH.readArrays src
20 in getArgs >>= S.drain . parallely . S.mapM sendFile . S.fromList