

pymdht_daemon listens on port 7000/TCP for RPC queries.

There are two kinds of API RPC queries:

- slow_get_peers
It produces a DHT lookup which is slow (around one second) but generates low
traffic. This kind of query should be used when the operation is not
latency-sensitive (e.g. announce).

- fast_get_peers
It produces a DHT lookup which is very fast (100-200 ms) but generates
lots of traffic (200-300 UDP packets). This kind of query should be used when
the operation is latency-sensitive (e.g. streaming).

== pymdht_daemon API RPC Spec ===

RPC queries are bencoded.
Both queries have the same arguments. 

Query example:
{'q': 'fast_get_peers', # either fast or slow get_peers
't': 'aa', # transaction ID (2 bytes)
      'a': { # arguments (dictionary)
           'info_hash': '12345678901234567890', # key (20 bytes)
           'port': 'ke', # port to announce (two bytes), 
                                # all zeros means don't announce
           }
}
Bencoded:
'd1:ad9:info_hash20:123456789012345678904:port2:kee1:q14:fast_get_peers1:t2:aae'

Response example (you will probably get several responses for a single query):
{'t': 'aa', # transaction ID (2 bytes)
'r': { # response (dictionary)
      'peers': [ # peers (list), the list can be empty
               '123456', # peer (6 bytes: IP/port)
               '523456', # peer (6 bytes: IP/port)
               ],
      'done': 1, # the lookup is done (integer used as boolean) 
      }
}
Bencoded:
'd1:rd4:donei1e5:peersl6:1234566:523456ee1:t2:aae'

Error example (for debugging only):
{'t': 'aa', # transaction ID (2 bytes)
'e': 'You forgot the port argument' # error msg (string, max 200 bytes)
}
Bencoded:
'd1:e28:You forgot the port argument1:t2:aae'





