on master help sign in
rename listen* APIs to accept*
977a072Harendra Kumar
examples/EchoServer.hs+1−1
@@ -11,6 +11,6 @@ import qualified Streamly.Prelude as S
11main :: IO ()
11main :: IO ()
12main = S.drain
12main = S.drain
13 $ parallely $ S.mapM (useWith echo)
13 $ parallely $ S.mapM (useWith echo)
14− $ serially $ S.unfold TCP.listenOnPort 8090
14+ $ serially $ S.unfold TCP.acceptOnPort 8090
15 where echo sk = S.fold (writeArrays sk) $ S.unfold readArraysOf (32768, sk)
15 where echo sk = S.fold (writeArrays sk) $ S.unfold readArraysOf (32768, sk)
16 useWith f sk = finally (liftIO (Net.close sk)) (f sk)
16 useWith f sk = finally (liftIO (Net.close sk)) (f sk)
examples/FileSinkServer.hs+1−1
@@ -27,7 +27,7 @@ main = do
27 $ encodeChar8Unchecked
27 $ encodeChar8Unchecked
28 $ S.concatUnfold A.read
28 $ S.concatUnfold A.read
29 $ S.concatMapWith parallel use
29 $ S.concatMapWith parallel use
30− $ S.unfold TCP.listenOnPort 8090)
30+ $ S.unfold TCP.acceptOnPort 8090)
31
31
32 where
32 where
33
33
src/Streamly/Internal/Network/Inet/TCP.hs+18−19
@@ -21,13 +21,12 @@
21module Streamly.Internal.Network.Inet.TCP
21module Streamly.Internal.Network.Inet.TCP
22 (
22 (
23 -- * TCP Servers
23 -- * TCP Servers
24− -- ** Connected sockets
25− -- *** Unfolds
24+ -- ** Unfolds
26− listenOnAddr
25+ acceptOnAddr
27− , listenOnPort
26+ , acceptOnPort
28− , listenOnPortLocal
27+ , acceptOnPortLocal
29
28
30− -- *** Streams
29+ -- ** Streams
31 , connections
30 , connections
32 , connectionsOnAddr
31 , connectionsOnAddr
33 , connectionsOnAllAddrs
32 , connectionsOnAllAddrs
@@ -120,11 +119,11 @@ import qualified Streamly.Internal.Network.Socket as ISK
120-- connections are accepted.
119-- connections are accepted.
121--
120--
122-- @since 0.7.0
121-- @since 0.7.0
123−{-# INLINE listenOnAddr #-}
122+{-# INLINE acceptOnAddr #-}
124−listenOnAddr
123+acceptOnAddr
125 :: MonadIO m
124 :: MonadIO m
126 => Unfold m ((Word8, Word8, Word8, Word8), PortNumber) Socket
125 => Unfold m ((Word8, Word8, Word8, Word8), PortNumber) Socket
127−listenOnAddr = UF.lmap f listen
126+acceptOnAddr = UF.lmap f listen
128 where
127 where
129 f (addr, port) =
128 f (addr, port) =
130 (maxListenQueue
129 (maxListenQueue
@@ -137,27 +136,27 @@ listenOnAddr = UF.lmap f listen
137 , SockAddrInet port (tupleToHostAddress addr)
136 , SockAddrInet port (tupleToHostAddress addr)
138 )
137 )
139
138
140−-- | Like 'listenOnAddr' but binds on the IPv4 address @0.0.0.0@ i.e. on all
139+-- | Like 'acceptOnAddr' but binds on the IPv4 address @0.0.0.0@ i.e. on all
141-- IPv4 addresses/interfaces of the machine and listens for TCP connections on
140-- IPv4 addresses/interfaces of the machine and listens for TCP connections on
142-- the specified port.
141-- the specified port.
143--
142--
144−-- > listenOnPort = UF.supplyFirst listenOnAddr (0,0,0,0)
143+-- > acceptOnPort = UF.supplyFirst acceptOnAddr (0,0,0,0)
145--
144--
146-- @since 0.7.0
145-- @since 0.7.0
147−{-# INLINE listenOnPort #-}
146+{-# INLINE acceptOnPort #-}
148−listenOnPort :: MonadIO m => Unfold m PortNumber Socket
147+acceptOnPort :: MonadIO m => Unfold m PortNumber Socket
149−listenOnPort = UF.supplyFirst listenOnAddr (0,0,0,0)
148+acceptOnPort = UF.supplyFirst acceptOnAddr (0,0,0,0)
150
149
151−-- | Like 'listenOnAddr' but binds on the localhost IPv4 address @127.0.0.1@.
150+-- | Like 'acceptOnAddr' but binds on the localhost IPv4 address @127.0.0.1@.
152-- The server can only be accessed from the local host, it cannot be accessed
151-- The server can only be accessed from the local host, it cannot be accessed
153-- from other hosts on the network.
152-- from other hosts on the network.
154--
153--
155−-- > listenOnPortLocal = UF.supplyFirst listenOnAddr (127,0,0,1)
154+-- > acceptOnPortLocal = UF.supplyFirst acceptOnAddr (127,0,0,1)
156--
155--
157-- @since 0.7.0
156-- @since 0.7.0
158−{-# INLINE listenOnPortLocal #-}
157+{-# INLINE acceptOnPortLocal #-}
159−listenOnPortLocal :: MonadIO m => Unfold m PortNumber Socket
158+acceptOnPortLocal :: MonadIO m => Unfold m PortNumber Socket
160−listenOnPortLocal = UF.supplyFirst listenOnAddr (127,0,0,1)
159+acceptOnPortLocal = UF.supplyFirst acceptOnAddr (127,0,0,1)
161
160
162-------------------------------------------------------------------------------
161-------------------------------------------------------------------------------
163-- Listen
162-- Listen
src/Streamly/Network/Inet/TCP.hs+3−3
@@ -15,9 +15,9 @@
15module Streamly.Network.Inet.TCP
15module Streamly.Network.Inet.TCP
16 (
16 (
17 -- * Accept Connections
17 -- * Accept Connections
18− listenOnAddr
18+ acceptOnAddr
19− , listenOnPort
19+ , acceptOnPort
20− , listenOnPortLocal
20+ , acceptOnPortLocal
21
21
22 {-
22 {-
23 -- ** Sink Servers
23 -- ** Sink Servers