So last weekend, I was looking for something to do and somehow ended up on the bittorrent protocol page... So now I'm developing a bittorrent client in C#. Hooray!
Vexingly, for client-tracker communication, there's no concept of string encoding and no distinction between binary strings and text strings, so I just keep them as byte arrays until I know they're filenames or ip addresses or something, then I convert with utf-8. (.NET makes that easy, at least)
One gripe about .NET is that there's a BinaryWriter that lets you write ints and stuff out as bytes, but there's no flag or anything to make it output big-endian. I finally found the good old HostToNetworkOrder style functions as static methods in IPAddress of all classes. Maybe I'll make some kind of BinaryWriter/Reader wrappers that do the conversions for you...
One odd thing about the bittorrent protocol that proves it was made as a secret DDOS weapon is that when you tell the tracker you want to start downloading (and thus invite other people to connect to you) you can give it a different IP address (and port) than the one you're coming from... I don't know if any trackers actually allow it (trackers should be quite easy to make as cgi scripts), but it seems like you could sign your least favorite website up on all the popular trackers as having a seed for each of the most popular anime/pr0n/lunix iso files and have a ton of people connect to their port 80 for the freebies. Or just post a TheMatrixReloaded.DVD.ForRealZ!.mpg.torrent on a newsgroup and list their website as the tracker. Owel, time will tell, I guess.
--regolith
|