network-bytestring 0.1.1.1 → 0.1.1.2
raw patch · 2 files changed
+22/−13 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Network/Socket/ByteString.cpphs +21/−12
- network-bytestring.cabal +1/−1
Network/Socket/ByteString.cpphs view
@@ -9,7 +9,7 @@ -- Stability : experimental -- Portability : portable ----- | A module for efficiently transmitting data over sockets. For+-- A module for efficiently transmitting data over sockets. For -- detailed documentation consult your favorite POSIX socket -- reference. All functions communicate failures by converting the -- error number to an 'System.IO.IOError'.@@ -37,7 +37,8 @@ import Control.Monad (liftM) import Data.ByteString (ByteString) import qualified Data.ByteString as B-import Data.ByteString.Internal (create)+import Data.Word (Word8)+import Data.ByteString.Internal (createAndTrim) import Data.ByteString.Unsafe (unsafeUseAsCStringLen) import Foreign.C.Error import Foreign.C.Types (CChar, CInt, CSize)@@ -114,21 +115,29 @@ recv sock@(MkSocket s _ _ _ _) nbytes | nbytes <= 0 = ioError (mkInvalidRecvArgError "Network.Socket.ByteString.recv") | otherwise = do- create nbytes $ \ptr -> do- len <-+ createAndTrim nbytes $ recvInner s nbytes++-- | This is a helper function which allows up to loop in the case of EINTR+recvInner :: CInt -> Int -> Ptr Word8 -> IO Int+recvInner s nbytes ptr = do+ len <- #if defined(__GLASGOW_HASKELL__) && defined(mingw32_HOST_OS)- readRawBufferPtr "Network.Socket.ByteString.recvLen" (fromIntegral s) True- (castPtr ptr) 0 (fromIntegral nbytes)+ readRawBufferPtr "Network.Socket.ByteString.recvLen" (fromIntegral s) True+ (castPtr ptr) 0 (fromIntegral nbytes) #else # if !defined(__HUGS__)- throwErrnoIfMinus1Retry_repeatOnBlock "recv"- (threadWaitRead (fromIntegral s)) $+ throwErrnoIfMinus1Retry_repeatOnBlock "recv"+ (threadWaitRead (fromIntegral s)) $ # endif- c_recv s (castPtr ptr) (fromIntegral nbytes) 0{-flags-}+ c_recv s (castPtr ptr) (fromIntegral nbytes) 0{-flags-} #endif- if fromIntegral len == 0- then ioError (mkEOFError "Network.Socket.ByteString.recv")- else return ()+ case fromIntegral len of+ 0 -> ioError (mkEOFError "Network.Socket.ByteString.recv")+ (-1) -> do errno <- getErrno+ if errno == eINTR+ then recvInner s nbytes ptr+ else throwErrno "Network.Socket.ByteString.recv"+ n -> return n -- | Similar to 'recv' but can be used to receive data on a socket -- that is not connection-oriented.
network-bytestring.cabal view
@@ -1,5 +1,5 @@ name: network-bytestring-version: 0.1.1.1+version: 0.1.1.2 synopsis: Fast and memory efficient low-level networking description: Faster and more memory efficient low-level socket functions using 'Data.ByteString's instead of