Libtorrent Session_Status 未更新

Libtorrent Session_Status not updating

我正在尝试 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,会话也始终处于侦听状态,并且即使互联网关闭,也始终存在连接。

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

*Session_Status = Session->status();

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