【发布时间】: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