Socket notifiers cannot send from another thread
-
Hello,
I have a big problem with threads.I have a Terminal class that inherits from a CScada class (C++ DLL).
The CScada class has a Receive function. This receives data that I have to analyze and pass on to the client via a socket interface.
RClient ---- Socket ---- Terminal(CScada) ----- CustomApp
override Receive function.I would probably have to send a SendMessage from the Receive function to the terminal, then from there the response via socket to the client. How should I do this?
Thanks for tipps in advance. QT 5.6.X version
@RobertSommer said in Socket notifiers cannot send from another thread:
QT 5.6.X version
Just out of interest: Why such an antique version?
-
@RobertSommer said in Socket notifiers cannot send from another thread:
How should I do this?
How should we know? There is no code...
Use signals and slots to make sure the function call is made in the correct thread.@Christian-Ehrlicher said in Socket notifiers cannot send from another thread:
How should we know? There is no code...
Use signals and slots to make sure the function call is made in the correct thread.I am a beginner and do not know how to implement this.
RClient ---- Socket ---- Terminal(CScada) ----- CustomApp
override Receive function.Have you understood the problem?
I have a Console application, class Terminal that inherits from CScada. This has a receive function in it, when data arrives I have to read and analyze it, then send a response via socket to the client. Then comes , not possible from another thread.connect (pointer_to_ink, &Ink::ready, this, &Controller(Terminal)::correspondingSlot) //Instance: pointer_to_ink // Event: ready //then call --> correspondingSlot from my controller(Terminal)
I don't have two objects now, just the terminal.
How can I solve this? -
@RobertSommer said in Socket notifiers cannot send from another thread:
QT 5.6.X version
Just out of interest: Why such an antique version?
@Axel-Spoerl said in Socket notifiers cannot send from another thread:
Just out of interest: Why such an antique version?
I am a beginner and a colleague gave me this to test whether QT is better than C#.
What is the current free version? And where can I get it?
-
-
@Axel-Spoerl said in Socket notifiers cannot send from another thread:
Just out of interest: Why such an antique version?
I am a beginner and a colleague gave me this to test whether QT is better than C#.
What is the current free version? And where can I get it?
@RobertSommer said in Socket notifiers cannot send from another thread:
whether QT is better than C#
Qt is not a programming language.
You can't compare these two.
Is a banana better than a bicycle?You can compare C++ with C#
Or WinForms/WPF with Qt.not possible from another thread
At least show what your setup looks like... from the connection only we can't tell what you are doing (wrong).
-
@RobertSommer said in Socket notifiers cannot send from another thread:
whether QT is better than C#
Qt is not a programming language.
You can't compare these two.
Is a banana better than a bicycle?You can compare C++ with C#
Or WinForms/WPF with Qt.not possible from another thread
At least show what your setup looks like... from the connection only we can't tell what you are doing (wrong).
@Pl45m4
ok.Have you understood my problem?
connect (pointer_to_ink, &Ink::ready, this, &Controller(Terminal)::correspondingSlot)
like this, is not possible, because I'm inside the Controller(Terminal) class.
The class inherits from CScada, which has a ReceiveData function. Event based. This is called when changes are made.I check the data and want to send it to the client via a socket interface.
When I call the SendtoSocketClient function, not allowed comes from another thread. The problem.Maybe I need to implement a SendMessage logic. Can you show me how this could work?
A connect via signal and slot is not possible, as I am in the same class. -
@RobertSommer said in Socket notifiers cannot send from another thread:
whether QT is better than C#
Qt is not a programming language.
You can't compare these two.
Is a banana better than a bicycle?You can compare C++ with C#
Or WinForms/WPF with Qt.not possible from another thread
At least show what your setup looks like... from the connection only we can't tell what you are doing (wrong).
@Pl45m4 said in Socket notifiers cannot send from another thread:
@RobertSommer said in Socket notifiers cannot send from another thread:
whether QT is better than C#
Qt is not a programming language.
You can't compare these two.I just guess what OP says is to compare Qt and .NET ...Amalgams between C# and .NET are common as C# is tightly coupled to .NET (and those amalgams seem to be even more common for Java and JDK) by people who eigher don't bother make the difference, or downright don't even know about.
-
@RobertSommer
Nobody can tell you why the code doesn’t work, because we don’t know what the terminal class is. You need to boil the issue down to a minimal compilable reproducer, small enough to post it here, directly, using the </> code tags, to get the format right. Please also specify what exactly “is not possible” means: Does the connect statement not compile? Does it compile but the connection goes wrong? Is a warning printed? A compile error? -
@RobertSommer
Nobody can tell you why the code doesn’t work, because we don’t know what the terminal class is. You need to boil the issue down to a minimal compilable reproducer, small enough to post it here, directly, using the </> code tags, to get the format right. Please also specify what exactly “is not possible” means: Does the connect statement not compile? Does it compile but the connection goes wrong? Is a warning printed? A compile error?@Axel-Spoerl said in Socket notifiers cannot send from another thread:
@RobertSommer
Nobody can tell you why the code doesn’t work,Sure.
Can a signal be set by an inherited receive function, event?
If so, how? I don't have a code because I don't know. -
@Axel-Spoerl said in Socket notifiers cannot send from another thread:
@RobertSommer
Nobody can tell you why the code doesn’t work,Sure.
Can a signal be set by an inherited receive function, event?
If so, how? I don't have a code because I don't know.@RobertSommer said in Socket notifiers cannot send from another thread:
Can a signal be set by an inherited receive function, event?
Set?!
You can emit a signal wherever you can also call a function.
But depends on your logic if that makes sense.