Creation and integration of the libtorrent library in a .NET environment
$100-500 USD
Posted about 15 years ago
$100-500 USD
Paid on delivery
The objective is to generate the libtorrent library (Rasterbar libtorrent opensource version 0.14.1) and integrate it into a Microsoft Visual Studio .Net Managed C++ project.
## Deliverables
The objective is to generate the libtorrent library (Rasterbar libtorrent opensource version 0.14.1) and integrate it into a Microsoft Visual Studio .Net Managed C++ project.
To demonstrate a working result the library that you generate must be integrated into 2 projects : dump_torrent and simple_client.
The source code for each project is included below.
Both of the projects as described here are written in Unmanaged C++ and you must convert them to Managed C++ without altering their functionality.
The dump_torrent program produces a content analysis of a torrent file supplied as a parameter.
The simple_client program downloads the file(s) mentioned in a torrent file supplied as a parameter.
The deliverables for the project are :
Deliverable 1 : A C++ project for building the libtorrent library
Deliverable 2 : A Managed C++ project for building a working version of the dump_torrent executable (exploiting deliverable 1)
Deliverable 3 : A Managed C++ project for building a working version of the simple_client executable (exploiting deliverable 1)
The solution must be compatible with Microsoft Visual Studio 2008 Express Edition.
All source code, libraries and VC++ project files must be included in the solution such that the deliverables can be rebuilt by us.
LINKS :
The Rasterbar libtorrent opensource version 0.14.1 source code is available at :
<[login to view URL]>
Information on the generation of the libtorrent library is available at :
<[login to view URL]>
<[login to view URL]>
NOTES :
Libtorrent is dependant on further libraries such as boost, openssl, asio, zlib.
SOURCE CODE...
________________________________________________________________________________________________
dump_torrent :
________________________________________________________________________________________________
#include <iostream>
#include <fstream>
#include <iterator>
#include <iomanip>
#include "libtorrent/[login to view URL]"
#include "libtorrent/[login to view URL]"
#include "libtorrent/[login to view URL]"
#include "libtorrent/[login to view URL]"
#include <boost/filesystem/[login to view URL]>
int main(int argc, char* argv[])
{
? ? ? ? ? ? using namespace libtorrent;
? ? ? ? ? ? using namespace boost::filesystem;
? ? ? ? ? ? if (argc != 2)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cerr << "usage: dump_torrent torrent-file\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
#if BOOST_VERSION < 103400
boost::filesystem::path::default_name_check(boost::filesystem::no_check);
#endif
#ifndef BOOST_NO_EXCEPTIONS
? ? ? ? ? ? try
? ? ? ? ? ? {
#endif
? ? ? ? ? ? ? ? ? ? ? ? ? ? int size = file_size(argv[1]);
? ? ? ? ? ? ? ? ? ? ? ? ? ? if (size > 10 * 1000000)
? ? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cerr << "file too big (" << size << "), aborting\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::vector<char> buf(size);
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::ifstream(argv[1], std::ios_base::binary).read(&buf[0], size);
? ? ? ? ? ? ? ? ? ? ? ? ? ? lazy_entry e;
? ? ? ? ? ? ? ? ? ? ? ? ? ? int ret = lazy_bdecode(&buf[0], &buf[0] + [login to view URL](), e);
? ? ? ? ? ? ? ? ? ? ? ? ? ? if (ret != 0)
? ? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cerr << "invalid bencoding: " << ret << std::endl;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "\n\n----- raw info -----\n\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << e << std::endl;
? ? ? ? ? ? ? ? ? ? ? ? ? ? torrent_info t(e);
? ? ? ? ? ? ? ? ? ? ? ? ? ? // print info about torrent
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "\n\n----- torrent file info -----\n\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "nodes:\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? typedef std::vector<std::pair<std::string, int> > node_vec;
? ? ? ? ? ? ? ? ? ? ? ? ? ? node_vec const& nodes = [login to view URL]();
? ? ? ? ? ? ? ? ? ? ? ? ? ? for (node_vec::const_iterator i = [login to view URL](), end([login to view URL]());
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? i != end; ++i)
? ? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << i->first << ":" << i->second << "\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "trackers:\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? for (std::vector<announce_entry>::const_iterator i = [login to view URL]().begin();
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? i != [login to view URL]().end(); ++i)
? ? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << i->tier << ": " << i->url << "\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "number of pieces: " << t.num_pieces() << "\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "piece length: " << t.piece_length() << "\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "info hash: " << t.info_hash() << "\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "comment: " << [login to view URL]() << "\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "created by: " << [login to view URL]() << "\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "files:\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? int index = 0;
? ? ? ? ? ? ? ? ? ? ? ? ? ? for (torrent_info::file_iterator i = t.begin_files();
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? i != t.end_files(); ++i, ++index)
? ? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int first = t.map_file(index, 0, 1).piece;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int last = t.map_file(index, i->size - 1, 1).piece;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << "? " << std::setw(11) << i->size
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? << " " << i->[login to view URL]() << "[ " << first << ", "
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? << last << " ]\n";
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
#ifndef BOOST_NO_EXCEPTIONS
? ? ? ? ? ? }
? ? ? ? ? ? catch (std::exception& e)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << [login to view URL]() << "\n";
? ? ? ? ? ? }
#endif
? ? ? ? ? ? return 0;
}
________________________________________________________________________________________________
simple_client :
________________________________________________________________________________________________
int main(int argc, char* argv[])
{
? ? ? ? ? ? using namespace libtorrent;
#if BOOST_VERSION < 103400
? ? ? ? ? ? namespace fs = boost::filesystem;
? ? ? ? ? ? fs::path::default_name_check(fs::no_check);
#endif
if (argc != 2)
{
? ? ? ? ? ? std::cerr << "usage: ./simple_client torrent-file\n"
? ? ? ? ? ? ? ? ? ? ? ? ? ? "to stop the client, press return.\n";
? ? ? ? ? ? return 1;
}
#ifndef BOOST_NO_EXCEPTIONS
? ? ? ? ? ? try
#endif
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? session s;
? ? ? ? ? ? ? ? ? ? ? ? ? ? s.listen_on(std::make_pair(6881, 6889));
? ? ? ? ? ? ? ? ? ? ? ? ? ? add_torrent_params p;
? ? ? ? ? ? ? ? ? ? ? ? ? ? p.save_path = "./";
? ? ? ? ? ? ? ? ? ? ? ? ? ? [login to view URL] = new torrent_info(argv[1]);
? ? ? ? ? ? ? ? ? ? ? ? ? ? s.add_torrent(p);
? ? ? ? ? ? ? ? ? ? ? ? ? ? // wait for the user to end
? ? ? ? ? ? ? ? ? ? ? ? ? ? char a;
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::[login to view URL](std::ios_base::skipws);
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cin >> a;
? ? ? ? ? ? }
#ifndef BOOST_NO_EXCEPTIONS
? ? ? ? ? ? catch (std::exception& e)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? std::cout << [login to view URL]() << "\n";
? ? ? ? ? ? }
#endif
? ? ? ? ? ? return 0;
}
Project ID: 3611958
About the project
3 proposals
Remote project
Active 15 yrs ago
Looking to make some money?
Benefits of bidding on Freelancer
Set your budget and timeframe
It's free to sign up and bid on jobs
3 freelancers are bidding on average $133 USD for this job
$102 USD in 15 days
3.8 (7 reviews) $212.50 USD in 15 days
0.0 (1 review)