diff options
Diffstat (limited to 'src/Network/BitTorrent.hs')
-rw-r--r-- | src/Network/BitTorrent.hs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/Network/BitTorrent.hs b/src/Network/BitTorrent.hs index f7c4c004..7ec0a067 100644 --- a/src/Network/BitTorrent.hs +++ b/src/Network/BitTorrent.hs | |||
@@ -29,9 +29,14 @@ module Network.BitTorrent | |||
29 | , awaitEvent, yieldEvent | 29 | , awaitEvent, yieldEvent |
30 | ) where | 30 | ) where |
31 | 31 | ||
32 | import Control.Concurrent | ||
33 | import Control.Exception | ||
32 | import Control.Monad | 34 | import Control.Monad |
35 | |||
33 | import Data.IORef | 36 | import Data.IORef |
34 | 37 | ||
38 | import Network | ||
39 | |||
35 | import Data.Torrent | 40 | import Data.Torrent |
36 | import Network.BitTorrent.Internal | 41 | import Network.BitTorrent.Internal |
37 | import Network.BitTorrent.Exchange | 42 | import Network.BitTorrent.Exchange |
@@ -45,6 +50,8 @@ import Network.BitTorrent.Tracker | |||
45 | 50 | ||
46 | discover :: SwarmSession -> P2P () -> IO () | 51 | discover :: SwarmSession -> P2P () -> IO () |
47 | discover swarm action = do | 52 | discover swarm action = do |
53 | port <- listener swarm action | ||
54 | |||
48 | let conn = TConnection (tAnnounce (torrentMeta swarm)) | 55 | let conn = TConnection (tAnnounce (torrentMeta swarm)) |
49 | (tInfoHash (torrentMeta swarm)) | 56 | (tInfoHash (torrentMeta swarm)) |
50 | (clientPeerID (clientSession swarm)) | 57 | (clientPeerID (clientSession swarm)) |
@@ -57,8 +64,14 @@ discover swarm action = do | |||
57 | forever $ do | 64 | forever $ do |
58 | addr <- getPeerAddr tses | 65 | addr <- getPeerAddr tses |
59 | putStrLn "connecting to peer" | 66 | putStrLn "connecting to peer" |
60 | withPeer swarm addr action | 67 | handle handler (withPeer swarm addr action) |
61 | |||
62 | 68 | ||
69 | where | ||
70 | handler :: IOException -> IO () | ||
71 | handler _ = return () | ||
63 | 72 | ||
64 | port = 10000 | 73 | listener :: SwarmSession -> P2P () -> IO PortNumber |
74 | listener _ _ = do | ||
75 | -- TODO: | ||
76 | -- forkIO loop | ||
77 | return 10000 | ||