如何使用 twisted 连接到以下 url 并从跟踪器获取响应。udp://tracker.publicbt.com:80/announce?uploaded=0&downloaded=0&compact=1&event=started&peer_id=kovid_agarwal1235467&port=6881&info_hash=3389809f0c9096819294a680beb4adb96a738419&left=763922958
我尝试了以下代码,但出现连接 ID 不匹配错误
from twisted.internet.protocol import DatagramProtocol
from MakeUrlRequest import encoded_Value
class SendAndReceiveUDP(DatagramProtocol):
def startProtocol(self):
self.transport.connect("31.172.124.3",80)
self.transport.write(encoded_Value())
def datagramReceived(self, datagram, addr):
print "Received %r" %datagram
from twisted.internet import reactor
udpclient=SendAndReceiveUDP()
reactor.listenUDP(6881,udpclient)
reactor.run()
上面的encoded_Value就是如下值:uploaded=0&downloaded=0&compact=1&event=started&peer_id=kovid_agarwal1235467&port=6881&info_hash=3389809f0c9096819294a680beb4adb96a738419&left=763922958