@@ -91,22 +91,31 @@ spell init0 siz0 recv recvBuf
9191
9292receive :: Socket -> BufferPool -> Recv
9393receive sock pool = withBufferPool pool $ \ (ptr, size) -> do
94− let sock' = fdSocket sock
95− size' = fromIntegral size
96− fromIntegral <$> receiveloop sock' ptr size'
94+#if MIN_VERSION_network(3,0,0)
95+ fd <- fdSocket sock
96+#else
97+ let fd = fdSocket sock
98+#endif
99+ let size' = fromIntegral size
100+ fromIntegral <$> receiveloop fd ptr size'
97101
98102receiveBuf :: Socket -> RecvBuf
99−receiveBuf sock buf0 siz0 = loop buf0 siz0
103+receiveBuf sock buf0 siz0 = do
104+#if MIN_VERSION_network(3,0,0)
105+ fd <- fdSocket sock
106+#else
107+ let fd = fdSocket sock
108+#endif
109+ loop fd buf0 siz0
100110 where
101− loop _ 0 = return True
102− loop buf siz = do
111+ loop _ _ 0 = return True
112+ loop fd buf siz = do
103113 n <- fromIntegral <$> receiveloop fd buf (fromIntegral siz)
104114 -- fixme: what should we do in the case of n == 0
105115 if n == 0 then
106116 return False
107117 else
108− loop (buf `plusPtr` n) (siz - n)
109− fd = fdSocket sock
118+ loop fd (buf `plusPtr` n) (siz - n)
110119
111120receiveloop :: CInt -> Ptr Word8 -> CSize -> IO CInt
112121receiveloop sock ptr size = do