S
S
Sazoks2020-08-27 12:00:49
Qt
Sazoks, 2020-08-27 12:00:49

Why doesn't the signal fire in Qt?

In the stream, I create a socket and make a connection:

mTcpSocket = new QTcpSocket;
mTcpSocket->setSocketDescriptor(mSockD);
connect(mTcpSocket, &QTcpSocket::readyRead, this, &Listener::SlotMessageAccepted);

Those. when data is received, a method is called to process it.
The problem is that when the server sends data, this thing doesn't work...
But the data definitely goes to the socket!
When the above code I wrote this:
QByteArray Block;
_sock->waitForReadyRead();
while (_sock->bytesAvailable() > 0)
    Block.append(_sock->readAll());

Data was received and recorded in Block. Those. the problem, as I understand it, is not in the delivery of data, but in the connection.
But how to fix the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sazoks, 2020-08-27
@Sazoks

I figured out what the problem is. The problem is that all incoming data goes to the socket, which is in the main thread, and nothing just reaches the socket in the other thread.
Tell me, is it possible to somehow tell sockets to either only read or only send data?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question