summaryrefslogtreecommitdiff
path: root/exsamples/Main.hs
blob: 81958613fc9a4a9b77432cd068472dde873f9aca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Main (main) where

import Control.Concurrent
import Data.Bitfield
import Network.BitTorrent
import System.Environment
import Control.Monad.Reader


main :: IO ()
main = do
  [path] <- getArgs
  torrent <- fromFile path

  client  <- newClient []
  swarm   <- newLeacher  client torrent

  discover swarm $ do
    addr <- asks connectedPeerAddr
    liftIO $ print $ "connected to" ++ show addr
    e <- awaitEvent
    liftIO $ print e
    liftIO $ threadDelay (100 * 1000000)

  print "Bye-bye! =_="