Hibernating Torrent: A simple torrent server for Windows
I think that I already mentioned that I started to run into scaling limits with my screen casts. More specifically, the latest screen cast, was already downloaded 7,300 times! It is a 160Mb file, it also means that I have to pay for obscene amount of traffic.
Since I didn't want to pay for all that bandwidth, and since in principal I don't believe in having to pay to give something (which cost a lot to make) for free, I was in somewhat of a problem.
The idea of torrents was very attractive, except...
There are no torrents servers for windows. Oh, you can try to use uTorrent using all sorts of hacks using srvany.exe from the resource kits, and hope that it would work (it didn't for me), or you can try using Azureus (still didn't work for me) and pay ~120Mb RAM just for that. The situation seemed hopeless and I toured the halls of the secret laboratory despondent, pondering the situation for many nights.
Then I recalled that I am a developer, therefor I have the power to create things. A quick search on Google led me to BitSharp / MonoTorrent a torrent library in C#. I had to learn how to use it, but it didn't take long, and I wrote my own Torrent Server, which is currently live and used to host my screen casts.
I think that I am doing too much networking stuff lately. Torrent server, subversion server, caching server (see subversion server).
Comments
Nice, that could be useful. Subversion server?
What do you think SvnBridge is?
Oh sure - yeah, why not, yeah. Write your own torrent server. Do it in about 40 lines of code maybe. Nice. (Argh wishes things worked out this easy when I did them).
Miles,
It is about 25 lines of code or so.
Sorry.
Hey Ayende,
It certainly is very elegant/spare code. It was great to look at it.
For what its worth I did have a look at the code and count the lines (very roughly) in TorrentServer.cs - that was a little less than 40 lines of what I would call 'meaningful' code but then I figured you have to count in HibernatingTorrent.cs as well, and that brings it up in the 40+ lines of code.. still how does one define 'meaningful' lines of code! ;-)
(If you could define it and get a computer to work that out, it would maybe be an actually useful LOC metric)
My metric is how much code I need to make it happen, without making it ready for production
@Ayende
Sorry i didn't think about SvnBridge, thought you talked about SVN hosting in IIS or something...
I for one am glad to see you moving into some new areas. Most of the programming we do is of the real-time nature - in fact, most of our code that goes from browser->IIS->database is baked.
With more of my time being spent on real-time systems that go from the desktop through various systems internally and even to some external systems, communications are my primary focus and it is good to see some additional minds focused on the subject.
Your recent activity with NServiceBus (and others) is a good thing to see!
Now if we could just write a nice torrent tracker for Windows...
while it is cool and all, I'm not sure I see the point of making your own tracking server when there are plenty of free ones available that can give you metrics.
http://www.thepiratebay.org/register
http://www.legaltorrents.com/signup
http://www.mininova.org/distribution
there are tons more, that's just the ones that are somewhat known.
John,
This one is a seeding server, so I don't need to deal with that.
I have a server that will always seed the files I want, so the torrent never stops being seeded
Nice piece of code!
Why not codeplex the server?
Because I already have a code repository that I can use, and for 40 lines of code, I am not really interested in creating a new project.
Doesn't seem like a very frictionless technology...
I am not following
Not sure where this comment should go, but Episode 4 is corrupt (won't unzip).
Joe,
Yes, I verified that this is the case, checking now
Should be fixed now.
The torrent files are served up with a text mime type. In firefox this means that they are automatically handled by Notepad rather than the default torrent program. Torrent files should be served as application/x-bittorrent rather than text/plain.
Comment preview