From 8ea2e1f83ba7c06646f200107a018daf4a434bf9 Mon Sep 17 00:00:00 2001 From: Sam T Date: Sun, 7 Jul 2013 22:21:05 +0400 Subject: ~ Refactor torrent registration a bit. --- src/Network/BitTorrent/Peer.hs | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'src/Network/BitTorrent/Peer.hs') 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 -- * Peer address , PeerAddr(..) , peerSockAddr - , connectToPeer, forkListener + , connectToPeer , ppPeer -- * Client version detection @@ -540,28 +540,6 @@ connectToPeer p = do connect sock (peerSockAddr p) return sock - -forkListener :: ((PeerAddr, Socket) -> IO ()) -> IO PortNumber -forkListener action = do - sock <- socket AF_INET Stream defaultProtocol - bindSocket sock (SockAddrInet 0 0) - listen sock 1 - addr <- getSocketName sock - case addr of - SockAddrInet port _ -> do - forkIO (loop sock) - return port - _ -> do - throwIO $ userError "listener: impossible happened" - where - loop sock = do - (conn, addr) <- accept sock - case addr of - SockAddrInet port host -> - action (PeerAddr Nothing host port, conn) - _ -> return () - loop sock - -- | Pretty print peer address in human readable form. ppPeer :: PeerAddr -> Doc ppPeer p @ PeerAddr {..} = case peerID of -- cgit v1.2.3