on master help sign in
Move Network/Server module to Network/Socket/Inet/TCP
commit49d3698bda26252a48b09e37a187295ab217891d authorHarendra Kumar <harendra.kumar@gmail.com> dateMon 14 Oct 2019, 01:53 (7 years ago) parent48fc6bf
4 files changed+14−10
examples/EchoServer.hs+8−5 examples/FileSinkServer.hs+2−2 src/Streamly/Network/Server.hs → src/Streamly/Network/Socket/Inet/TCP.hs+2−2 streamly.cabal+2−1
examples/EchoServer.hs+8−5
@@ -1,13 +1,16 @@
11-- A concurrent TCP server that echoes everything that it receives.
22
3+import Control.Exception (finally)
4+import Control.Monad.IO.Class (liftIO)
35import Streamly
4−import Streamly.Internal.Network.Socket (useSocketM, readArrays)
56import Streamly.Network.Socket
6−import Streamly.Network.Server
7+import qualified Network.Socket as Net
8+import qualified Streamly.Network.Socket.Inet.TCP as TCP
79import qualified Streamly.Prelude as S
810
911main :: IO ()
1012main = S.drain
11− $ parallely $ S.mapM (flip useSocketM echo)
12− $ serially $ S.unfold listenOnPort 8090
13− where echo sk = S.fold (writeArrays sk) $ S.unfold readArrays sk
13+ $ parallely $ S.mapM (useWith echo)
14+ $ serially $ S.unfold TCP.listenOnPort 8090
15+ where echo sk = S.fold (writeArrays sk) $ S.unfold readArraysOf (32768, sk)
16+ useWith f sk = finally (liftIO (Net.close sk)) (f sk)
examples/FileSinkServer.hs+2−2
@@ -14,7 +14,7 @@ import Streamly.Data.String
1414import qualified Streamly.FileSystem.Handle as FH
1515import qualified Streamly.Memory.Array as A
1616import qualified Streamly.Network.Socket as NS
17−import qualified Streamly.Network.Server as NS
17+import qualified Streamly.Network.Socket.Inet.TCP as TCP
1818import qualified Streamly.Prelude as S
1919
2020import System.IO (withFile, IOMode(..))
@@ -27,7 +27,7 @@ main = do
2727 $ encodeChar8Unchecked
2828 $ S.concatUnfold A.read
2929 $ S.concatMapWith parallel use
30− $ S.unfold NS.listenOnPort 8090)
30+ $ S.unfold TCP.listenOnPort 8090)
3131
3232 where
3333
src/Streamly/Network/Server.hs → src/Streamly/Network/Socket/Inet/TCP.hsrenamed+2−2
@@ -7,12 +7,12 @@
77-- Stability : experimental
88-- Portability : GHC
99--
10−-- Combinators to build network servers.
10+-- Combinators to build TCP servers.
1111--
1212-- > import qualified Streamly.Network.Server as Server
1313--
1414
15−module Streamly.Network.Server
15+module Streamly.Network.Socket.Inet.TCP
1616 (
1717 -- * Accept Connections
1818 listenOnAddr
streamly.cabal+2−1
@@ -316,7 +316,7 @@ library
316316 if !impl(ghcjs)
317317 exposed-modules:
318318 Streamly.Network.Socket
319− , Streamly.Network.Server
319+ , Streamly.Network.Socket.Inet.TCP
320320 , Streamly.Network.Client
321321
322322 , Streamly.Internal.Network.Socket
@@ -903,6 +903,7 @@ executable EchoServer
903903 build-Depends:
904904 streamly
905905 , base >= 4.8 && < 5
906+ , network >= 2.6 && < 4
906907 else
907908 buildable: False
908909