on 523f606 help sign in
streamly/examples/FromFileClient.hs
20 lines 544 B history raw
1-- A TCP client that reads from stdin and sends to a server
3import Network.Socket
4import System.IO (stdin)
6import qualified Streamly.Prelude as S
7import qualified Streamly.FileSystem.File as File
8import qualified Streamly.Network.Socket as NS
10main :: IO ()
11main = do
12 openConnection >>= \sk ->
13 S.drain $ NS.writeArrays sk $ File.readArrays stdin
15 where
17 openConnection = do
18 sock <- socket AF_INET Stream defaultProtocol
19 connect sock $ SockAddrInet 8090 (tupleToHostAddress (127,0,0,1))
20 return sock