Is "QSocket notifiers cannot be enabled or disabled from another thread" warning bad?
-
hi!
I am using a socket in multiple threads and when using i get this warning message"QSocket notifiers cannot be enabled or disabled from another thread". Though the data is sent and received through that socket without any problem, i am concerned about the warning. Can anyone tell whether it is safe to neglect that warning? -
Can anyone tell whether it is safe to neglect that warning?
probably not, but no-one can stop you.
But do tell, why are you carrying the mountain to the prophet, instead of letting the prophet walk himself ?
What I mean, make one socket handling class, use signals to transmit the data you want to send via TcpSocket, return the received data also via Signals emitted from the tcpsocket thread. Don't carry your socket around, especially across multiple threads.
-
Hi,
It would also be nice to show how exactly you are using that socket from multiple threads.
-
I created seperate thread for manage tcp operations(connect, disconnect,write, read). and put that thread in exec(). and the used signals and slot method to communicate between the threads. and the error which i mentioned is not coming now .
-
@ManiRon
waitForReadyRead()
is at best "dodgy" under Windows --- you have never said what platform you are on --- and has threading implications. Have a read through e.g. https://stackoverflow.com/questions/44544684/is-it-ok-to-use-waitforreadyread-instead-of-creating-a-slot-for-readyread. Why do you need it all, when you could design to be signal/slot instead which is better?