void sendPing(IPEndPoint destination, byte[] token) { var dict = Bencoding.Dict(); dict.Set("t", token); dict.Set("y", "q"); dict.Set("q", "ping"); dict.Set("ro", 1); var args = Bencoding.Dict(); args.Set("id", nodeId); dict.Set("a", args); var encoded = Bencoding.Encode(dict); socket.SendTo(encoded, destination); }
void sendGetPeers(IPEndPoint destination, byte[] token, byte[] infohash) { var dict = Bencoding.Dict(); dict.Set("t", token); dict.Set("y", "q"); dict.Set("q", "get_peers"); dict.Set("ro", 1); var args = Bencoding.Dict(); args.Set("id", nodeId); args.Set("info_hash", infohash); dict.Set("a", args); var encoded = Bencoding.Encode(dict); socket.SendTo(encoded, destination); }