mirror of
https://github.com/composewell/streamly.git
synced 2024-09-20 07:58:27 +03:00
22 lines
708 B
Haskell
22 lines
708 B
Haskell
-- A TCP client that does the following:
|
|
-- * Reads multiple filenames passed on the command line
|
|
-- * Opens as many concurrent connections to the server
|
|
-- * Sends all the files concurrently to the server
|
|
|
|
import System.Environment (getArgs)
|
|
|
|
import Streamly
|
|
import qualified Streamly.Prelude as S
|
|
import qualified Streamly.FileSystem.Handle as FH
|
|
import qualified Streamly.Network.Client as Client
|
|
|
|
import System.IO (withFile, IOMode(..))
|
|
|
|
main :: IO ()
|
|
main =
|
|
let sendFile file =
|
|
withFile file ReadMode $ \src ->
|
|
S.runFold (Client.writeArrays (127, 0, 0, 1) 8090)
|
|
$ FH.readArrays src
|
|
in getArgs >>= S.drain . parallely . S.mapM sendFile . S.fromList
|