gpt4 book ai didi

c++ - Libtorrent Session_Status 未更新

转载 作者:行者123 更新时间:2023-11-28 00:12:22 25 4
gpt4 key购买 nike

我试图让 Session_Status 更新,但由于某种原因,结构的值永远不会更新, session 是这样启动的:

 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, session 也始终在监听,即使互联网关闭,也始终有连接。

最佳答案

我相信您打算将 session 状态分配给您的 Session_Status 对象:

*Session_Status = Session->status();

我建议您不要堆分配 session_status 或 session_settings 对象。

关于c++ - Libtorrent Session_Status 未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32298517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com