@@ -38,11 +38,12 @@ module Streamly.Internal.Network.Inet.TCP
3838
3939 -- ** Unfolds
4040 , withServerAddr
41+ , read
4142
4243 -- ** Streams
4344 , withConnection
4445 -- *** Source
45− , read
46+ , toStream
4647 -- , readUtf8
4748 -- , readLines
4849 -- , readFrames
@@ -109,6 +110,7 @@ import Streamly.Streams.StreamK.Type (IsStream)
109110
110111import qualified Network.Socket as Net
111112import qualified Streamly.Internal.Data.Unfold as UF
113+import qualified Streamly.Internal.Memory.Array as A
112114import qualified Streamly.Internal.Memory.ArrayStream as AS
113115import qualified Streamly.Internal.Data.Fold.Types as FL
114116import qualified Streamly.Prelude as S
@@ -279,9 +281,17 @@ withConnection addr port =
279281--
280282-- @since 0.7.0
281283{-# INLINE read #-}
282−read :: (IsStream t, MonadCatch m, MonadIO m)
284+read :: (MonadCatch m, MonadIO m)
285+ => Unfold m ((Word8, Word8, Word8, Word8), PortNumber) Word8
286+read = UF.concat (withServerAddr ISK.readArrays) A.read
287+
288+-- | Read a stream from the supplied IPv4 host address and port number.
289+--
290+-- @since 0.7.0
291+{-# INLINE toStream #-}
292+toStream :: (IsStream t, MonadCatch m, MonadIO m)
283293 => (Word8, Word8, Word8, Word8) -> PortNumber -> t m Word8
284−read addr port = AS.concat $ withConnection addr port ISK.toStreamArrays
294+toStream addr port = AS.concat $ withConnection addr port ISK.toStreamArrays
285295
286296-------------------------------------------------------------------------------
287297-- Writing