summaryrefslogtreecommitdiff
path: root/examples/Client.hs
blob: 0ed4bb6f218c332e0f0fff124d4a233eae979045 (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
26
module Main (main) where
import Control.Concurrent
import Control.Monad.Trans
import System.Environment
import System.Exit
import System.IO
import Network.BitTorrent


parseArgs :: IO FilePath
parseArgs = do
  args <- getArgs
  case args of
    [path] -> return path
    _      -> do
      hPutStrLn stderr "Usage: client file.torrent"
      exitFailure

main :: IO ()
main = do
  path    <- parseArgs
  torrent <- fromFile path
  simpleClient $ do
    h <- openTorrent torrent
    start h
    liftIO $ threadDelay 10000000000