summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Peer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Peer.hs')
-rw-r--r--src/Network/BitTorrent/Peer.hs24
1 files changed, 1 insertions, 23 deletions
diff --git a/src/Network/BitTorrent/Peer.hs b/src/Network/BitTorrent/Peer.hs
index 68771052..4615ad3a 100644
--- a/src/Network/BitTorrent/Peer.hs
+++ b/src/Network/BitTorrent/Peer.hs
@@ -51,7 +51,7 @@ module Network.BitTorrent.Peer
51 -- * Peer address 51 -- * Peer address
52 , PeerAddr(..) 52 , PeerAddr(..)
53 , peerSockAddr 53 , peerSockAddr
54 , connectToPeer, forkListener 54 , connectToPeer
55 , ppPeer 55 , ppPeer
56 56
57 -- * Client version detection 57 -- * Client version detection
@@ -540,28 +540,6 @@ connectToPeer p = do
540 connect sock (peerSockAddr p) 540 connect sock (peerSockAddr p)
541 return sock 541 return sock
542 542
543
544forkListener :: ((PeerAddr, Socket) -> IO ()) -> IO PortNumber
545forkListener action = do
546 sock <- socket AF_INET Stream defaultProtocol
547 bindSocket sock (SockAddrInet 0 0)
548 listen sock 1
549 addr <- getSocketName sock
550 case addr of
551 SockAddrInet port _ -> do
552 forkIO (loop sock)
553 return port
554 _ -> do
555 throwIO $ userError "listener: impossible happened"
556 where
557 loop sock = do
558 (conn, addr) <- accept sock
559 case addr of
560 SockAddrInet port host ->
561 action (PeerAddr Nothing host port, conn)
562 _ -> return ()
563 loop sock
564
565-- | Pretty print peer address in human readable form. 543-- | Pretty print peer address in human readable form.
566ppPeer :: PeerAddr -> Doc 544ppPeer :: PeerAddr -> Doc
567ppPeer p @ PeerAddr {..} = case peerID of 545ppPeer p @ PeerAddr {..} = case peerID of