python bittorrent 对等协议(protocol)无法连接到任何对等点

标签 python sockets bittorrent

我正在尝试了解有关 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/

相关文章:

python - 在 Jupyter Notebook 中重新运行导入

java - 集群环境下socket切换

Java Socket 服务器未从客户端套接字接收数据

bittorrent - IPFS 和 Bittorrent 中的分布式哈希表如何防止滥用?

bittorrent - 在哪里可以找到 BitTorrent 源代码?

bittorrent - DHT中announce_peer的token

python - 从 OpenErp 中删除模块安装队列

python - 生成额外输出的正则表达式

python - 将 Python 添加到 Twitter Bootstrap

C++:使用选择()