Reputation: 610
I am learning about BitTorrent protocol and I managed to make a simple little program that can load a torrent file, parse it, get a tracker from it, then send a GET request to the tracker, and do a handshake with one peer. But now I came by a UDP tracker in the form udp://example.to:999/announce
.
With a regular tracker I would do (in C#):
HttpWebRequest request =(HttpWebRequest)WebRequest.Create(request_string);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
How do I send a request and get a response with an UDP tracker?
Upvotes: 1
Views: 1308
Reputation: 610
The class I needed in C# was System.Net.Sockets.UdpClient
. If your udp tracker address is udp://example.to:999/announce
, then you need to initialize your UdpClient with:
UdpClient udpTracker = new UdpClient("example.to", 999);
Then use appropriate methods for sending and receiving information. For what needs to be sent to the tracker refer to UDP Tracker Protocol.
Upvotes: 0
Reputation: 2090
You need to implement the UDP Tracker Protocol that is specified in:
BEP15 - UDP Tracker Protocol.
Upvotes: 1