Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Socket notifiers cannot send from another thread

Socket notifiers cannot send from another thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 5 Posters 285 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RobertSommer
    wrote 14 days ago last edited by
    #1

    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

    C A 2 Replies Last reply 14 days ago
    0
    • R RobertSommer
      14 days ago

      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

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote 14 days ago last edited by
      #2

      @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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      R 1 Reply Last reply 13 days ago
      1
      • R RobertSommer
        14 days ago

        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

        A Offline
        A Offline
        Axel Spoerl
        Moderators
        wrote 13 days ago last edited by
        #3

        @RobertSommer said in Socket notifiers cannot send from another thread:

        QT 5.6.X version

        Just out of interest: Why such an antique version?

        Software Engineer
        The Qt Company, Oslo

        R 1 Reply Last reply 13 days ago
        0
        • C Christian Ehrlicher
          14 days ago

          @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.

          R Offline
          R Offline
          RobertSommer
          wrote 13 days ago last edited by
          #4

          @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?

          1 Reply Last reply
          0
          • A Axel Spoerl
            13 days ago

            @RobertSommer said in Socket notifiers cannot send from another thread:

            QT 5.6.X version

            Just out of interest: Why such an antique version?

            R Offline
            R Offline
            RobertSommer
            wrote 13 days ago last edited by
            #5

            @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?

            P 1 Reply Last reply 12 days ago
            0
            • A Offline
              A Offline
              Axel Spoerl
              Moderators
              wrote 13 days ago last edited by
              #6

              https://www.qt.io/download-dev

              Software Engineer
              The Qt Company, Oslo

              1 Reply Last reply
              0
              • R RobertSommer
                13 days ago

                @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?

                P Offline
                P Offline
                Pl45m4
                wrote 12 days ago last edited by Pl45m4 5 Feb 2025, 20:39
                #7

                @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).


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                R C 2 Replies Last reply 11 days ago
                0
                • P Pl45m4
                  12 days ago

                  @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).

                  R Offline
                  R Offline
                  RobertSommer
                  wrote 11 days ago last edited by
                  #8

                  @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.

                  1 Reply Last reply
                  0
                  • P Pl45m4
                    12 days ago

                    @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).

                    C Offline
                    C Offline
                    CassD
                    wrote 11 days ago last edited by CassD 5 Mar 2025, 15:28
                    #9

                    @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.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Axel Spoerl
                      Moderators
                      wrote 11 days ago last edited by
                      #10

                      @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?

                      Software Engineer
                      The Qt Company, Oslo

                      R 1 Reply Last reply 10 days ago
                      0
                      • A Axel Spoerl
                        11 days ago

                        @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?

                        R Offline
                        R Offline
                        RobertSommer
                        wrote 10 days ago last edited by
                        #11

                        @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.

                        P 1 Reply Last reply 10 days ago
                        0
                        • R RobertSommer
                          10 days ago

                          @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.

                          P Offline
                          P Offline
                          Pl45m4
                          wrote 10 days ago last edited by
                          #12

                          @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.


                          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                          ~E. W. Dijkstra

                          1 Reply Last reply
                          0

                          1/12

                          1 May 2025, 12:37

                          • Login

                          • Login or register to search.
                          1 out of 12
                          • First post
                            1/12
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved