Answer the question
In order to leave comments, you need to log in
How to handshake with a peer on a BitTorrent network?
Here is my code:
import socket
import time
sock = socket.socket()
sock.connect((peer_id, peer_port))
message = b'\x13BitTorrent protocol\x00\x00\x00\x00\x00\x00\x00\x00' + bytes('1A6948C96FA8302C74DA680C7360D1486A52B2F9'.lower(), encoding="UTF8") + b'66788486352714431784'
sock.send(message)
print('s')
while True:
try:
resp = sock.recv(len(message))
print(resp)
if resp != b'':
break
except:
pass
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question