network-attoparsec 0.10.1 → 0.11.0
raw patch · 2 files changed
+9/−9 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
network-attoparsec.cabal view
@@ -1,6 +1,6 @@ name: network-attoparsec category: Network, Parsing -version: 0.10.1 +version: 0.11.0 license: MIT license-file: LICENSE copyright: (c) 2015 Leon Mergen @@ -32,6 +32,7 @@ , mtl , network + , network-simple , attoparsec , bytestring
src/Network/Attoparsec.hs view
@@ -22,6 +22,7 @@ import qualified Data.ByteString as BS import qualified Network.Socket as NS import qualified Network.Socket.ByteString as NSB +import qualified Network.Simple.TCP as Network import qualified Data.Attoparsec.ByteString as Atto -- | The parsing continuation form of a "Data.Attoparsec" parser. This is @@ -127,11 +128,9 @@ , MonadMask m) => NS.Socket -> m BS.ByteString -readAvailable s = - let doRead = NSB.recv s 4096 - tryRead = tryAny doRead - - in do - conn <- liftIO $ NS.isConnected s - res <- liftIO tryRead - either throwM return res +readAvailable s = do + buf <- liftIO $ Network.recv s 4096 + liftIO $ putStrLn ("received buffer: " ++ show buf) + case buf of + Just d -> return d + Nothing -> return BS.empty