我试图更新Session_Status,但无论出于何种原因,结构的值永远不会更新,会话就像这样开始:
using namespace libtorrent;
session* Session;
session_status* Session_Status;
session_settings* Session_Settings;
bool Start_Client_Sess ( )
{
using namespace libtorrent;
Session = new session;
Session_Status = new session_status;
Session_Settings = new session_settings;
Session->settings ( );
Session->set_settings ( *Session_Settings );
Session->add_extension ( create_ut_pex_plugin );
Session->add_extension ( create_ut_metadata_plugin );
Session->add_extension ( create_lt_trackers_plugin );
Session->add_extension ( create_smart_ban_plugin );
Session->start_upnp ( );
Session->start_natpmp ( );
Session->start_dht ( );
Session->start_lsd ( );
error_code e;
Session->listen_on ( std::make_pair ( 6881 , 6889 ) , e );
if ( e )
{
return false;
}
return true;
}
然后在Windows 1秒计时器上我这样做:
void RunTimer ( )
{
using namespace libtorrent;
Session->status ( );
if ( Session->is_listening ( ) )
{
if ( Session_Status->has_incoming_connections )
{
INT x = 2;
std::cout << x << "\n";
}
else
{
INT x = 1;
std::cout << x << "\n";
}
}
else
{
INT x = 0;
std::cout << x << "\n";
}
}
但是无论会话总是在听什么,即使防火墙阻止了Libtorrent,即使互联网关闭也总是有连接。
答案 0 :(得分:3)
我相信您的意思是将会话状态分配给Session_Status对象:
*Session_Status = Session->status();
我建议你不要分配session_status和session_settings对象。