c# - UDP Tracker not responding -


alright, i'm trying connect udp trackers using c#, never response. don't errors. here's code.

namespace udptester {     class mainclass     {         public static bool messagereceived = false;         public static random random = new random();         public static void log(string format, params object[] args)         {             console.writeline (format,args);             }         public static void main (string[] args)         {             log ("creating packet...");             byte[] packet;             using(var stream = new memorystream())             {                 var bc = new miscutil.conversion.bigendianbitconverter();                 using(var br = new miscutil.io.endianbinarywriter(bc,stream))                 {                     log ("magic num: {0}",(int64)0x41727101980);                     br.write (0x41727101980);                     br.write((int32)0);                     br.write ((int32)random.next());                     packet = stream.toarray();                     log ("packet size: {0}",packet.length);                 }             }             log ("connecting tracker...");             var client = new system.net.sockets.udpclient("tracker.openbittorrent.com",80);             udpstate s = new udpstate();             s.e = client.client.remoteendpoint;             s.u = client;             startreceiving(s);              log ("sending packet...");             client.send(packet,packet.length);             while(!messagereceived)             {                     thread.sleep(1000);             }             log ("ended");          }         public static void startreceiving(udpstate state)         {             state.u.beginreceive(receivecallback,state);         }          public static void receivecallback(iasyncresult ar)         {             udpclient u = (udpclient)((udpstate)(ar.asyncstate)).u;             ipendpoint e = (ipendpoint)((udpstate)(ar.asyncstate)).e;              byte[] receivebytes = u.endreceive(ar, ref e);             string receivestring = encoding.ascii.getstring(receivebytes);              log("received: {0}", receivestring);             messagereceived = true;             startreceiving((udpstate)ar.asyncstate);         }      }     public class udpstate     {         public udpclient u;         public endpoint e;     } } 

i using normal binarywriter, didn't work, , read somewhere wants it's data in bigendian.

this doesn't work of udp trackers i've found, ideas why i'm not getting response? did maybe change protocol , not tell anyone? http trackers work fine.

trackers i've tried

udp://tracker.publicbt.com:80

udp://tracker.ccc.de:80

udp://tracker.istole.it:80

also, i'm not interested in using monotorrent(and when using it, udp didn't work anyways).

protocol sources

http://xbtt.sourceforge.net/udp_tracker_protocol.html

http://www.rasterbar.com/products/libtorrent/udp_tracker_protocol.html

udp connectionless protocol, won't see errors if packets lost or dropped @ destination.

try following diagnostic steps:

  1. use packet sniffer (wireshark one) check udp packets leaving machine.
  2. install working bittorrent client, check if can communicate tracker , if yes, use packet sniffer see how packets sent working client differ packets code generates.

if working client can not communicate tracker, udp traffic leaving machine, udp packets dropped firewall. can try 'traceroute' tool diagnose packets dropped (this not 100% reliable, because firewalls drop udp packets generated traceroute , not drop normal udp traffic).


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -