summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/Torrent/PeerID.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Network/Torrent/PeerID.hs b/src/Network/Torrent/PeerID.hs
index a3394b36..3f41b99a 100644
--- a/src/Network/Torrent/PeerID.hs
+++ b/src/Network/Torrent/PeerID.hs
@@ -5,7 +5,8 @@
5-- 5--
6module Network.Torrent.PeerID 6module Network.Torrent.PeerID
7 ( -- ^ Peer addr 7 ( -- ^ Peer addr
8 Peer(..), peerSockAddr 8 Peer(..)
9 , peerSockAddr, connectToPeer
9 10
10 -- ^ Peer identification 11 -- ^ Peer identification
11 , PeerID (getPeerID) 12 , PeerID (getPeerID)
@@ -70,6 +71,14 @@ peerSockAddr = SockAddrInet <$> (g . peerPort) <*> (htonl . peerIP)
70 g :: PortNumber -> PortNumber 71 g :: PortNumber -> PortNumber
71 g (PortNum x) = PortNum x -- $ (x `shiftR` 8) .|. (x `shiftL` 8) 72 g (PortNum x) = PortNum x -- $ (x `shiftR` 8) .|. (x `shiftL` 8)
72 73
74-- ipv6 extension
75-- | Tries to connect to peer using reasonable default parameters.
76--
77connectToPeer :: Peer -> IO Socket
78connectToPeer p = do
79 sock <- socket AF_INET Stream Network.Socket.defaultProtocol
80 connect sock (peerSockAddr p)
81 return sock
73 82
74 83
75-- | Peer identifier is exactly 20 bytes long bytestring. 84-- | Peer identifier is exactly 20 bytes long bytestring.