我正在尝试了解有关 bittorrent 协议(protocol)的更多信息,并且我成功地通过 UDP 获取了对等点列表。
我遇到问题的地方是与对等 IP 本身建立连接(甚至在发送握手之前)。我通常会遇到以下错误:A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
我已经尽可能多地阅读了,并且根据大多数文档:
After receiving a peer IP and port-number from the tracker, our client will to open a TCP connection to that peer. Once the connection is open, these peers will start to exchange messages using the peer protocol.
但是,我认为这并不像
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ip, port)) # where ip and port is obtained from the list of IPs and PORTS from the tracker
## This above 2 lines of codes is met with a connection attempt failed error.
据此p2p question on stackoverflow ,我需要做很多低级的事情才能连接到我从
UDP announce
获得的对等点列表。跟踪器。我应该如何与同行建立联系?
最佳答案
您可以阅读:http://www.bittorrent.org/beps/bep_0003.html .
如果要建立连接,则需要通过对等协议(protocol)/对等线协议(protocol)进行连接。所以需要使用utp或者TCP,纯UDP是不行的。并且消息格式需要遵循协议(protocol)。
关于python bittorrent 对等协议(protocol)无法连接到任何对等点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61735422/