【问题标题】:python bittorrent peer protocol unable to connect to any peerspython bittorrent 对等协议无法连接到任何对等点
【发布时间】:2020-05-11 17:18:40
【问题描述】:

我正在尝试了解有关 bittorrent 协议的更多信息,并且我成功地通过 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

根据大多数文档,我已经尽可能多地阅读:

从跟踪器接收到对等 IP 和端口号后,我们的客户端将打开到该对等的 TCP 连接。一旦连接打开,这些对等点将开始使用对等点协议交换消息。

但是,我认为这并不像

那么简单
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 跟踪器获得的对等点列表。

我应该如何与对等方建立连接?

【问题讨论】:

    标签: python sockets bittorrent


    【解决方案1】:

    您可以阅读:http://www.bittorrent.org/beps/bep_0003.html

    如果要建立连接,则需要通过对等协议/对等线协议进行连接。所以需要使用utp或者TCP,纯UDP是不行的。并且消息格式需要遵循协议。

    【讨论】:

      猜你喜欢
      • 2017-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多