The name is very mysterious, so here it is!
I write a client who behaves very synchronously. Due to the design of the protocol and the server, everything should happen sequentially (send a request, wait for a response, a response from a service, etc.), so I use blocking sockets. Here is the Qt.
In my application, I have a GUI thread, a command processing thread, and a script engine thread. I am creating a QTcpSocket in a command flow as part of my Client class. The Client class has various methods that boil down to writing to a socket, reading a certain number of bytes and returning a result.
The problem occurs when I try to directly call Client methods from the script engine thread. Qt sockets randomly fail and when using the Qt debug build I get the following warnings:
QSocketNotifier: socket notifiers cannot be enabled from another thread QSocketNotifier: socket notifiers cannot be disabled from another thread
At any time, when I call these methods from the command flow (when the client was created), I do not get these problems.
To just tell the situation:
Calling QAbstractSocket locking functions, such as waitForReadyRead() , from a thread other than where the socket was created (dynamically allocated), causes random behavior and debugging of statements / warnings.
Has anyone else experienced this? Ways around him?
Thanks in advance.
source share