on de680fb help sign in
streamly/examples/FromFileClient.hs
20 lines 705 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 qualified Streamly.Prelude as S
9import qualified Streamly.Internal.FileSystem.Handle as IFH
10import qualified Streamly.Internal.Network.Inet.TCP as TCP
12import System.IO (withFile, IOMode(..))
14main :: IO ()
15main =
16 let sendFile file =
17 withFile file ReadMode $ \src ->
18 S.fold (TCP.writeChunks (127, 0, 0, 1) 8090)
19 $ IFH.toChunks src
20 in getArgs >>= S.drain . S.parallely . S.mapM sendFile . S.fromList