1-- A concurrent TCP server that:
3-- * receives connections from clients
4-- * splits the incoming data into lines
5-- * lines from concurrent connections are merged into a single srteam
6-- * writes the line stream to an output file
8import Control.Monad.IO.Class (liftIO)
9import Network.Socket (close)
10import System.Environment (getArgs)
13import Streamly.Data.Unicode.Stream
14import qualified Streamly.FileSystem.Handle as FH
15import qualified Streamly.Memory.Array as A
16import qualified Streamly.Network.Socket as NS
17import qualified Streamly.Network.Inet.TCP as TCP
18import qualified Streamly.Prelude as S
20import System.IO (withFile, IOMode(..))
24 file <- fmap head getArgs
25 withFile file AppendMode
26 (\src -> S.fold (FH.write src)
28 $ S.concatUnfold A.read
29 $ S.concatMapWith parallel use
30 $ S.unfold TCP.acceptOnPort 8090)
34 use sk = S.finally (liftIO $ close sk) (recv sk)
36 S.splitWithSuffix (== '\n') A.write
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list