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
QtWS25 Last Chance

Socket notifiers cannot send from another thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 5 Posters 271 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 RobertSommer

    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

    Axel SpoerlA Online
    Axel SpoerlA Online
    Axel Spoerl
    Moderators
    wrote 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
    0
    • Christian EhrlicherC Christian Ehrlicher

      @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 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
      • Axel SpoerlA Axel Spoerl

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

        Pl45m4P 1 Reply Last reply
        0
        • Axel SpoerlA Online
          Axel SpoerlA Online
          Axel Spoerl
          Moderators
          wrote last edited by
          #6

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

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          0
          • R RobertSommer

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

            Pl45m4P Online
            Pl45m4P Online
            Pl45m4
            wrote last edited by Pl45m4
            #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
            0
            • Pl45m4P Pl45m4

              @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 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
              • Pl45m4P Pl45m4

                @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 last edited by CassD
                #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
                • Axel SpoerlA Online
                  Axel SpoerlA Online
                  Axel Spoerl
                  Moderators
                  wrote 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
                  0
                  • Axel SpoerlA Axel Spoerl

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

                    Pl45m4P 1 Reply Last reply
                    0
                    • R RobertSommer

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

                      Pl45m4P Online
                      Pl45m4P Online
                      Pl45m4
                      wrote 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

                      • Login

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