views:

81

answers:

1

I'm looking for a way to download torrents in a C# application. Ideally I would like bindings for a popular torrent library to .net, are there any?

Alternatively (this is a bit of a long shot) the application already has Lua built in, so if there are Lua bindings I can also work with that.

+1  A: 

There's MonoTorrent, written entirely in .Net and has pretty much all the features you'll need.

Mark H
How mature is MonoTorrent? An entirely C# implementation would be nice, but I was imagining that the native versions would be more mature and more frequently updated.
Martin
MonoTorrent is TERRIBLE. I have tried to use it, struggled with it for weeks, and finally dropped the whole thing. It is no longer being developed or supported, is full of bugs, and there is no documentation whatsoever. It's much easier if you hack together a P/Invoke wrapper for LibTorrent.
ShdNx
@ShdNx - MT is still under development by Alan Mcgovern - it's home is now on GitHub (http://github.com/mono/monotorrent/commits/master) Looks pretty active to me. As for documentation, I also felt that it was lacking, however, they're plenty of unit testing in there which doubles up as samples to show you how to use it (and perhaps find all these bugs you speak of.) However, I've only used the library for providing a torrent tracker, I've not written a torrent client with it.
Mark H
@Mark H: interesting, thank you for pointing that out! I have tried to use it some months ago, and abandoned it after terrible experiences. I have tried to contact Alan, even posted on the forums, but I never got a response. Even opened a topic here on SO. The API itself is structured pretty well, and I have only tried to use the client part, but I would really advise you to reconsider any use of MT.
ShdNx
So even with the recent activity, would you still warn me away from MT?
Martin
If so, are there any bindings already written for libtorrent?
Martin
About the idea of P/Invoking libtorrent, it's not very practical. Libtorrent is C++ written, and P/Invoke is useless for handling __thiscall. You could write a COM wrapper in C++/CLI around it, but I doubt it'll be easy work, and doubt anyone has done it so far. I wouldn't warn you away from MT if you need to be on .Net, because it's the only solution, even if it does have problems. Probably a more reasonable consideration would be to write your torrent downloader in a native C++ library, but expose a facade pattern as C functions which you can then P/Invoke from C#.
Mark H