00001
00002
00003
00004
00005
00006
00007
00008 #include <iostream>
00009 #include <fstream>
00010 #include <iterator>
00011 #include <exception>
00012
00013 #include <boost/format.hpp>
00014 #include <boost/date_time/posix_time/posix_time.hpp>
00015
00016 #include "libtorrent/entry.hpp"
00017 #include "libtorrent/bencode.hpp"
00018 #include "libtorrent/session.hpp"
00019
00020 int main(int argc, char* argv[])
00021 {
00022 using namespace libtorrent;
00023
00024 namespace fs = boost::filesystem;
00025 fs::path::default_name_check(fs::no_check);
00026
00027 if (argc != 2)
00028 {
00029 std::cerr << "usage: ./simple_client torrent-file\n"
00030 "to stop the client, press return.\n";
00031 return 1;
00032 }
00033
00034 try
00035 {
00036 session s;
00037 s.listen_on(std::make_pair(6881, 6889));
00038
00039 std::ifstream in(argv[1], std::ios_base::binary);
00040 in.unsetf(std::ios_base::skipws);
00041 entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
00042 s.add_torrent(torrent_info(e), "./");
00043
00044
00045 char a;
00046 std::cin.unsetf(std::ios_base::skipws);
00047 std::cin >> a;
00048 }
00049 catch (std::exception& e)
00050 {
00051 std::cout << e.what() << "\n";
00052 }
00053 return 0;
00054 }