Back in 2008 I was writing a Bittorrent client for the Mac, which never saw light of day. The specifications are confusing and always moving, and I gave up trying to interoperate with everything. It’s a lot of work.
I did however implement a class that was able to decode and encode Bittorrent encoded files. Thats the way .torrent files are encoded, and if you’re going to write a bittorrent client, this is the first bit you will need.
It had issues though, apparently, and Aiden Steele took it upon himself to fix it and release a fixed version. You can find it on GitHub.