QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
-
Hi,
Based on your code, you are moving socket between threads which you should not.
See the threaded fortune server example.
-
I have read that, but I don't know how to fix it. Is it only possible to remove this warning?
@rktech said in QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread:
Is it only possible to remove this warning?
You should fix the issue instead of removing the warning!
Did you check the example @SGaist gave you? -
@rktech said in QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread:
but I don't know, how to fix my code.
As shown in the example pass the socket fd instead the object to your thread. You have to override incomingConnection() as shown there.
-
@Christian-Ehrlicher I have read the example like three-times, but I still don't know how to fix it. Can you help me?
-
@Christian-Ehrlicher I have read the example like three-times, but I still don't know how to fix it. Can you help me?
@rktech said in QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread:
but I still don't know how to fix it.
You have to override incomingConnection() as shown there.
-
@Christian-Ehrlicher said in QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread:
@rktech said in QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread:
but I still don't know how to fix it.
You have to override incomingConnection() as shown there.
I have tried, but I don't know how to implement that into my code.
-
What exactly have you tried ?
-
You'll have to redesign your pool a bit to ensure that your sockets are created in the context of the run method of your QThread subclass.
-
You'll have to redesign your pool a bit to ensure that your sockets are created in the context of the run method of your QThread subclass.
-
You have to transfer the descriptor to your pool and there in your run method create new sockets when descriptors are added.
-
You have to transfer the descriptor to your pool and there in your run method create new sockets when descriptors are added.
-
You have to transfer the descriptor to your pool and there in your run method create new sockets when descriptors are added.
@SGaist I have (probably) successfully rewritten the Pool add method, but I have another problem. When I add this:
protected: void incomingConnection(qintptr socketDescriptor) override;
to myserver.h I get this error:
...\myserver.h:35: Chyba: only virtual member functions can be marked 'override'
(Chyba is Error in my local)
What I am doing wrong? -
@SGaist I have (probably) successfully rewritten the Pool add method, but I have another problem. When I add this:
protected: void incomingConnection(qintptr socketDescriptor) override;
to myserver.h I get this error:
...\myserver.h:35: Chyba: only virtual member functions can be marked 'override'
(Chyba is Error in my local)
What I am doing wrong?Hi
well it is virtual https://doc.qt.io/qt-5/qtcpserver.html#incomingConnection
so does Pool inherit QTcpServer ?
The error you get says "Hey, i dont see that funtion in base class, so you cant use override" -
Hi
well it is virtual https://doc.qt.io/qt-5/qtcpserver.html#incomingConnection
so does Pool inherit QTcpServer ?
The error you get says "Hey, i dont see that funtion in base class, so you cant use override"