我想寫一段代碼連接到一個FTP服務器使用Qt與c + +,我看到一些奇怪的結果。代碼如下所示QFtp hasPendingCommands()返回true,但從不發出commandStarted(int)信號
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;
}
現在讓wierdness開始...請注意,我已經重複了connectToHost
線。出於某種原因,如果我只是打電話說「我沒有命令,即使你給了我一個...... WTF !!!」只有當我撥打兩次電話時,hasPendingCommands()
纔會返回true
。此外,無論我是否撥打此電話一次或兩次,commandStarted(int)
信號都不會發射。
有沒有人有任何想法爲什麼會發生這種情況或如何解決它?在此先感謝球員:-)。
因此,一些進一步的調試顯示該命令正在開始,但執行從未完成。我嘗試連接的ftp服務器肯定存在。 – DrBards