msgLoop
) where
-import Prelude hiding (lookup, concat, replicate, splitAt, empty)
+import Prelude hiding (lookup, concat, replicate, splitAt, empty, writeFile)
-import System.IO
-import Data.ByteString (ByteString, pack, unpack, concat, hGet, hPut, singleton)
+import System.IO (Handle, BufferMode(..), hSetBuffering)
+import Data.ByteString (ByteString, pack, unpack, concat, hGet, hPut, singleton, writeFile)
import Data.ByteString.Lazy (fromStrict, fromChunks)
import qualified Data.ByteString.Char8 as BC (replicate, pack, length)
import Network (connectTo, PortID(..))
in
setBits ++ (go bs' (pos + 1))
+-- downloadPiece :: Integer -> Handle -> IO ()
+
+createDummyFile :: FilePath -> Int -> IO ()
+createDummyFile path size = do
+ writeFile path (BC.replicate size '\0')
+
-- loop1 :: shake hands with all peers, find out the pieces they have, form PieceData.
-- recvMsg :: Peer -> Handle -> Msg
msgLoop :: Handle -> ByteString -> IO ()