on master help sign in
rename listen* APIs to accept*
commit977a072ca3522ae1b59a446dd88f77f8fe378a59 authorHarendra Kumar <harendra.kumar@gmail.com> dateMon 14 Oct 2019, 13:40 (7 years ago) parent31c1788
4 files changed+23−24
examples/EchoServer.hs+1−1 examples/FileSinkServer.hs+1−1 src/Streamly/Internal/Network/Inet/TCP.hs+18−19 src/Streamly/Network/Inet/TCP.hs+3−3
examples/EchoServer.hs+1−1
@@ -11,6 +11,6 @@ import qualified Streamly.Prelude as S
1111main :: IO ()
1212main = S.drain
1313 $ parallely $ S.mapM (useWith echo)
14− $ serially $ S.unfold TCP.listenOnPort 8090
14+ $ serially $ S.unfold TCP.acceptOnPort 8090
1515 where echo sk = S.fold (writeArrays sk) $ S.unfold readArraysOf (32768, sk)
1616 useWith f sk = finally (liftIO (Net.close sk)) (f sk)
examples/FileSinkServer.hs+1−1
@@ -27,7 +27,7 @@ main = do
2727 $ encodeChar8Unchecked
2828 $ S.concatUnfold A.read
2929 $ S.concatMapWith parallel use
30− $ S.unfold TCP.listenOnPort 8090)
30+ $ S.unfold TCP.acceptOnPort 8090)
3131
3232 where
3333
src/Streamly/Internal/Network/Inet/TCP.hs+18−19
@@ -21,13 +21,12 @@
2121module Streamly.Internal.Network.Inet.TCP
2222 (
2323 -- * TCP Servers
24− -- ** Connected sockets
25− -- *** Unfolds
26− listenOnAddr
27− , listenOnPort
28− , listenOnPortLocal
24+ -- ** Unfolds
25+ acceptOnAddr
26+ , acceptOnPort
27+ , acceptOnPortLocal
2928
30− -- *** Streams
29+ -- ** Streams
3130 , connections
3231 , connectionsOnAddr
3332 , connectionsOnAllAddrs
@@ -120,11 +119,11 @@ import qualified Streamly.Internal.Network.Socket as ISK
120119-- connections are accepted.
121120--
122121-- @since 0.7.0
123−{-# INLINE listenOnAddr #-}
124−listenOnAddr
122+{-# INLINE acceptOnAddr #-}
123+acceptOnAddr
125124 :: MonadIO m
126125 => Unfold m ((Word8, Word8, Word8, Word8), PortNumber) Socket
127−listenOnAddr = UF.lmap f listen
126+acceptOnAddr = UF.lmap f listen
128127 where
129128 f (addr, port) =
130129 (maxListenQueue
@@ -137,27 +136,27 @@ listenOnAddr = UF.lmap f listen
137136 , SockAddrInet port (tupleToHostAddress addr)
138137 )
139138
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
141140-- IPv4 addresses/interfaces of the machine and listens for TCP connections on
142141-- the specified port.
143142--
144−-- > listenOnPort = UF.supplyFirst listenOnAddr (0,0,0,0)
143+-- > acceptOnPort = UF.supplyFirst acceptOnAddr (0,0,0,0)
145144--
146145-- @since 0.7.0
147−{-# INLINE listenOnPort #-}
148−listenOnPort :: MonadIO m => Unfold m PortNumber Socket
149−listenOnPort = UF.supplyFirst listenOnAddr (0,0,0,0)
146+{-# INLINE acceptOnPort #-}
147+acceptOnPort :: MonadIO m => Unfold m PortNumber Socket
148+acceptOnPort = UF.supplyFirst acceptOnAddr (0,0,0,0)
150149
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@.
152151-- The server can only be accessed from the local host, it cannot be accessed
153152-- from other hosts on the network.
154153--
155−-- > listenOnPortLocal = UF.supplyFirst listenOnAddr (127,0,0,1)
154+-- > acceptOnPortLocal = UF.supplyFirst acceptOnAddr (127,0,0,1)
156155--
157156-- @since 0.7.0
158−{-# INLINE listenOnPortLocal #-}
159−listenOnPortLocal :: MonadIO m => Unfold m PortNumber Socket
160−listenOnPortLocal = UF.supplyFirst listenOnAddr (127,0,0,1)
157+{-# INLINE acceptOnPortLocal #-}
158+acceptOnPortLocal :: MonadIO m => Unfold m PortNumber Socket
159+acceptOnPortLocal = UF.supplyFirst acceptOnAddr (127,0,0,1)
161160
162161-------------------------------------------------------------------------------
163162-- Listen
src/Streamly/Network/Inet/TCP.hs+3−3
@@ -15,9 +15,9 @@
1515module Streamly.Network.Inet.TCP
1616 (
1717 -- * Accept Connections
18− listenOnAddr
19− , listenOnPort
20− , listenOnPortLocal
18+ acceptOnAddr
19+ , acceptOnPort
20+ , acceptOnPortLocal
2121
2222 {-
2323 -- ** Sink Servers