3 ms·
A decade ago now, I wrote a bit torrent client [1] that started as a project for a software development class. I think the focus of the class was roadmaps and
by war1025 7y ago
A decade ago now, I wrote a bit torrent client [1] that started as a project for a software development class.
I think the focus of the class was roadmaps and other parts of the development process for a larger project. Most of the groups picked games or things like that. We chose to build a bit torrent client and I ended up continuing working on it for a year or so.
I was pretty proud of it at the time. I'm sure there are a bunch of implementation details that seemed like a great idea as a Sophomore in college that no longer sound so clever, but the implementation is pretty sound. I used it to download a lot of stuff over the years.
The part I think is most interesting is the code for managing the torrent pieces and writing them into the proper places for the various files within the torrent. (Not necessarily my implementation of it, just the math behind the process) [2]
I remember feeling really clever the first time everything came together and actually downloaded a full torrent. My first bit software development victory.
[1] https://github.com/war1025/Torrent https://github.com/war1025/Torrent
[2] https://github.com/war1025/Torrent/blob/piecereg/tcl/tm/torrent/file/impl/FileAccessManagerImpl.java https://github.com/war1025/Torrent/blob/piecereg/tcl/tm/torr...
- ScarZy 7y agoChapeau!
- userbinator 7y agoI used it to download a lot of stuff over the years. That's great to hear --- I know there are quite a few developers who would do lots of different projects, but only to the point of getting something that barely works, and then never use it again. Having it in regular use means you have to continue to fix bugs and make improvements, which a lot of developers unfortunately seem to hate doing, although it's often the more valuable skill. "A true craftsman makes his own tools," as the old saying goes.
- kccqzy 7y ago> The part I think is most interesting is the code for managing the torrent pieces and writing them into the proper places for the various files within the torrent. (Not necessarily my implementation of it, just the math behind the process) Can you explain a little bit how this is interesting mathematically? On first thought, it seems like you would probably use a lot of pwrite, or if want convenience over safety, mmap all the files and write directly to memory. Not to diminish your achievement, but I didn't immediately see anything interesting here. Can you explain a bit more?
- war1025 7y agoWhat I meant more-so was the math of a "piece" from a torrent is a fixed number of bytes. The way the files are laid out for a torrent, they are listed in some order in the initial torrent file, along with their individual lengths. The data for the torrent is then treated as the contiguous sequence of bytes for the files in the listed order. That contiguous sequence is then broken into "pieces" of whatever fixed size. So finding which file(s) and what position within those files piece 148, for example, goes to involves some math that is pretty straight forward all in all, but is still rewarding when it's the first time you've done such a thing.