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. Send data between processes via QSharedMemory
Forum Updated to NodeBB v4.3 + New Features

Send data between processes via QSharedMemory

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 4 Posters 7.5k Views 1 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    I don't remember if there's a limitation in the characters you can use as key, but i'd start with only ASCII stuff without any special signs.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    MR.SmithM 1 Reply Last reply
    1
    • MR.SmithM Offline
      MR.SmithM Offline
      MR.Smith
      wrote on last edited by
      #5

      I'm already try to run two copies of Qt application. And it can't transfet data from one thread to another.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #6

        What exact error are you getting ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        MR.SmithM 1 Reply Last reply
        0
        • SGaistS SGaist

          I don't remember if there's a limitation in the characters you can use as key, but i'd start with only ASCII stuff without any special signs.

          MR.SmithM Offline
          MR.SmithM Offline
          MR.Smith
          wrote on last edited by
          #7

          @SGaist I'm changed value of key to simple ASCII: "example".
          Not effect (((
          May be you have an example? I searching it in Google but only one example in qt.io was found.
          No any other(((

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #8

            Probably off topic, but did you consider using QLocalSocket and WINAPI Named Pipe instead

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            MR.SmithM 1 Reply Last reply
            2
            • VRoninV VRonin

              Probably off topic, but did you consider using QLocalSocket and WINAPI Named Pipe instead

              MR.SmithM Offline
              MR.SmithM Offline
              MR.Smith
              wrote on last edited by
              #9

              @VRonin Good idea. It's will be my fallback. I need to high speed data transfer (up to 10 MBit/s) and shared memory is a faster method of IPC. It's most suitable for my application.

              1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by VRonin
                #10

                Disclaimer

                what follows is just speculation, not advice.


                The problem with shared memory, as I understand it, is that is no way to signal the reader application that new data is available to consume.

                10 MBit/s is not a lot, named pipe should be able to manage it without a problem, in fact, a TCP socket connected to localhost should also be able to handle that transfer rate without a sweat. Both their typical transfer rates are in the multiple Gbit/sec

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                MR.SmithM 1 Reply Last reply
                2
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  Check the detailed documentation of QSharedMemory and the setNativeKey. They explain how to achieve communication with non Qt application.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  3
                  • SGaistS SGaist

                    What exact error are you getting ?

                    MR.SmithM Offline
                    MR.SmithM Offline
                    MR.Smith
                    wrote on last edited by
                    #12

                    @SGaist When I run two copies of Ot application and write some data to shared memory from one of them and the next trying read data from another I have problem: sharedMemory.isAttached() == FALSE for shared memory with same keys.

                    jsulmJ 1 Reply Last reply
                    0
                    • MR.SmithM MR.Smith

                      @SGaist When I run two copies of Ot application and write some data to shared memory from one of them and the next trying read data from another I have problem: sharedMemory.isAttached() == FALSE for shared memory with same keys.

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      @MR.Smith Didn't you say before that it is working when using two Qt apps and doesn't work if one app is not a Qt app?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      MR.SmithM 1 Reply Last reply
                      0
                      • VRoninV VRonin

                        Disclaimer

                        what follows is just speculation, not advice.


                        The problem with shared memory, as I understand it, is that is no way to signal the reader application that new data is available to consume.

                        10 MBit/s is not a lot, named pipe should be able to manage it without a problem, in fact, a TCP socket connected to localhost should also be able to handle that transfer rate without a sweat. Both their typical transfer rates are in the multiple Gbit/sec

                        MR.SmithM Offline
                        MR.SmithM Offline
                        MR.Smith
                        wrote on last edited by
                        #14

                        @VRonin Thank you for recommendation. I will try to use named pipe in my application. It's also good solution for my application.

                        1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @MR.Smith Didn't you say before that it is working when using two Qt apps and doesn't work if one app is not a Qt app?

                          MR.SmithM Offline
                          MR.SmithM Offline
                          MR.Smith
                          wrote on last edited by
                          #15

                          @jsulm Yes, it's true. I can transfer data from one Qt application to another copy of this Qt application, but I can't transfer data from Qt application to WinAPI application.

                          jsulmJ 1 Reply Last reply
                          0
                          • MR.SmithM MR.Smith

                            @jsulm Yes, it's true. I can transfer data from one Qt application to another copy of this Qt application, but I can't transfer data from Qt application to WinAPI application.

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #16

                            @MR.Smith @SGaist pointed out what you should try

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            1
                            • MR.SmithM Offline
                              MR.SmithM Offline
                              MR.Smith
                              wrote on last edited by
                              #17

                              I got successfully transfer data via named pipes. It's good solution and I will use it, not shared memory.
                              Thank you every one for your help and recommendations.

                              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