diff --git a/Network/Connection.hs b/Network/Connection.hs
--- a/Network/Connection.hs
+++ b/Network/Connection.hs
@@ -37,7 +37,10 @@
     ) where
 
 import Control.Applicative
+import Control.Monad ((>=>), when)
 import Control.Concurrent.MVar
+import qualified Control.Exception as E
+import qualified System.IO.Error as E
 
 import qualified Network.TLS as TLS
 import qualified Network.TLS.Extra as TLS
@@ -92,8 +95,14 @@
 withBuffer :: (ByteString -> IO (ByteString, b)) -> Connection -> IO b
 withBuffer f conn = modifyMVar (connectionBuffer conn) f
 
+setEOF :: Connection -> IO ()
+setEOF conn = modifyMVar_ (connectionEOF conn) (const (return True))
+
+checkEOF :: Connection -> IO ()
+checkEOF conn = readMVar (connectionEOF conn) >>= flip when (E.ioError $ E.mkIOError E.eofErrorType "" Nothing Nothing)
+
 connectionNew :: ConnectionParams -> ConnectionBackend -> IO Connection
-connectionNew p backend = Connection <$> newMVar backend <*> newMVar B.empty <*> pure (connectionHostname p, connectionPort p)
+connectionNew p backend = Connection <$> newMVar backend <*> newMVar B.empty <*> pure (connectionHostname p, connectionPort p) <*> newMVar False
 
 -- | Use an already established handle to create a connection object.
 --
@@ -121,7 +130,7 @@
 
 -- | Put a block of data in the connection.
 connectionPut :: Connection -> ByteString -> IO ()
-connectionPut connection content = withBackend doWrite connection
+connectionPut connection content = checkEOF connection >> withBackend doWrite connection
     where doWrite (ConnectionStream h) = B.hPut h content >> hFlush h
           doWrite (ConnectionTLS ctx)  = TLS.sendData ctx $ L.fromChunks [content]
 
@@ -140,13 +149,17 @@
 -- | Like 'connectionGetChunk', but return the unused portion to the buffer,
 -- where it will be the next chunk read.
 connectionGetChunk' :: Connection -> (ByteString -> (a, ByteString)) -> IO a
-connectionGetChunk' conn f = withBuffer getData conn
+connectionGetChunk' conn f = checkEOF conn >> withBuffer getData conn
   where getData buf
           | B.null buf = do
-              chunk <- withBackend getMoreData conn
+              chunk <- withBackend (getMoreData >=> markEOF) conn
               return $ swap $ f chunk
           | otherwise =
               return $ swap $ f buf
+
+        markEOF bs
+            | B.null bs = setEOF conn >> return bs
+            | otherwise = return bs
 
         getMoreData (ConnectionTLS tlsctx) = TLS.recvData tlsctx
         getMoreData (ConnectionStream h)   = B.hGetSome h (16 * 1024)
diff --git a/Network/Connection/Types.hs b/Network/Connection/Types.hs
--- a/Network/Connection/Types.hs
+++ b/Network/Connection/Types.hs
@@ -76,6 +76,7 @@
     { connectionBackend :: MVar ConnectionBackend
     , connectionBuffer  :: MVar ByteString
     , connectionID      :: (HostName, PortNumber)  -- ^ return a simple tuple of the port and hostname that we're connected to.
+    , connectionEOF     :: MVar Bool
     }
 
 -- | Shared values (certificate store, sessions, ..) between connections
diff --git a/connection.cabal b/connection.cabal
--- a/connection.cabal
+++ b/connection.cabal
@@ -1,5 +1,5 @@
 Name:                connection
-Version:             0.1.1
+Version:             0.1.2
 Description:
     Simple network library for all your connection need.
     .
