Hello all,
i have call MyServer that listens on a specific TCP port for incoming connections and sends some data when a connection has been established.
Therefore i made some unit tests (to get used to the qt test library). MyServer belongs to a library, which is a Qt library project. Then I have a project Tests that uses the subdirs template. Inside the MyServer subproject as Unit test.
The tests for connection establishment work fine, then I want to check if the server sends the data as it is supposed to do. My primal version of the test looks like this:
MyServer srv(nullptr);
QTcpSocket tcp;
tcp.connectToHost("127.0.0.1", 9997);
tcp.waitForConnected(3000);
QVERIFY(tcp.state() == QAbstractSocket::ConnectedState);
QVERIFY(tcp.bytesAvailable() > 0);
The second verify always fails. However, if I build an own console application performing the same operations the data arrives.
What is the problem?
Thank you!
Regards
↧