Qt で c++ を使用して FTP サーバーに接続するコードを作成しようとしていますが、奇妙な結果がいくつか見られます。コードは次のとおりです。
void eos::WeatherRadar::connectToServer()
{
m_bomServer = new QFtp;
connect( m_bomServer, SIGNAL( commandStarted( int ) ), this, SLOT( serverConnectStarted() ) );
connect( m_bomServer, SIGNAL( commandFinished( int, bool ) ), this, SLOT( serverConnectFinished() ) );
m_bomServer->connectToHost("ftp.bom.gov.au");
m_bomServer->connectToHost("ftp.bom.gov.au");
if ( m_bomServer->hasPendingCommands() )
std::cout << "I have commands to execute..." << std::endl;
else
std::cout << "I have no commands even though you just gave me one... WTF!!!" << std::endl;
}
さて、奇妙さを始めましょう...connectToHost
行を繰り返したことに注意してください。なんらかの理由で、その呼び出しを一度だけ行うと、「あなたが私にコマンドをくれたにもかかわらず、コマンドがありません... WTF !!!」と表示されます。hasPendingCommands()
を返すのは、その呼び出しを 2 回行ったときだけtrue
です。さらに、この呼び出しを 1 回実行しても 2 回実行しても、commandStarted(int)
シグナルが発信されることはありません。
なぜこれが起こるのか、またはそれを修正する方法を知っている人はいますか? よろしくお願いします:-)。