QTcpClient successfully connects, but not to my server. Where is it connecting?

后端 未结 3 1149
情歌与酒
情歌与酒 2021-02-10 15:09

I have successfully built a thin client/server using Qt\'s Tcp Sockets API. I know it works very well, because I have sent plenty of data over the wire and verified it. Howeve

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-10 15:31

    While QTEST_MAIN creates a QApplication and runs all your tests, it does so sequentially and not with an event loop. Therefore, while your socket can indeed connect to the server (meaning qTestSocket->waitForConnected() returns true), since the app doesn't return to an event loop, the QTcpServer's signal will not get emitted, and TcpCommSocketTest::connectDummyServer() never gets called.

    Try adding a call to qApp->processEvents() at the end of initTestCase(). It should let connectDummyServer() be called.

提交回复
热议问题