python bittorrent对等协议无法连接到任何对等协议。

问题描述 投票:1回答:1

我想了解更多关于bittorrent协议的知识,我成功地通过UDP获得了一个对等体的列表,但我遇到的问题是,如何连接到对等体的IP本身(甚至在发送握手之前)。

我遇到的问题是,如何连接到对等体的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. 

据此 在stackoverflow上的p2p问题为了使我能够连接到我从这个网站上获得的对等体列表,有很多低级的事情需要做。UDP announce 追踪者。

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

python sockets bittorrent
1个回答
0
投票

你可以阅读这个: http:/www.bittorrent.orgbepsbep_0003.html.

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

© www.soinside.com 2019 - 2024. All rights reserved.