diff --git a/Network/Socket/ByteString/IO.hsc b/Network/Socket/ByteString/IO.hsc index 83442548..382a40c2 100644 --- a/Network/Socket/ByteString/IO.hsc +++ b/Network/Socket/ByteString/IO.hsc @@ -95,9 +95,10 @@ sendAll :: Socket -- ^ Connected socket -> IO () sendAll _ "" = return () sendAll s bs = do + -- "send" throws an exception. sent <- send s bs waitWhen0 sent s - when (sent >= 0) $ sendAll s $ B.drop sent bs + when (sent /= B.length bs) $ sendAll s $ B.drop sent bs -- | Send data to the socket. The recipient can be specified -- explicitly, so the socket need not be in a connected state. diff --git a/Network/Socket/ByteString/Lazy/Posix.hs b/Network/Socket/ByteString/Lazy/Posix.hs index 5d799bea..cf08825a 100644 --- a/Network/Socket/ByteString/Lazy/Posix.hs +++ b/Network/Socket/ByteString/Lazy/Posix.hs @@ -52,6 +52,7 @@ sendAll -> IO () sendAll _ "" = return () sendAll s bs = do + -- "send" throws an exception. sent <- send s bs waitWhen0 (fromIntegral sent) s - when (sent >= 0) $ sendAll s $ L.drop sent bs + when (sent /= L.length bs) $ sendAll s $ L.drop sent bs diff --git a/Network/Socket/ByteString/Lazy/Windows.hs b/Network/Socket/ByteString/Lazy/Windows.hs index a703c67c..d96bf5cc 100644 --- a/Network/Socket/ByteString/Lazy/Windows.hs +++ b/Network/Socket/ByteString/Lazy/Windows.hs @@ -30,6 +30,7 @@ sendAll -> IO () sendAll _ "" = return () sendAll s bs = do + -- "send" throws an exception. sent <- send s bs waitWhen0 (fromIntegral sent) s - when (sent >= 0) $ sendAll s $ L.drop sent bs + when (sent /= L.length bs) $ sendAll s $ L.drop sent bs