Send data between processes via QSharedMemory
-
wrote on 20 Feb 2017, 13:08 last edited by
I'm already try to run two copies of Qt application. And it can't transfet data from one thread to another.
-
What exact error are you getting ?
-
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.
-
wrote on 20 Feb 2017, 14:35 last edited by
Probably off topic, but did you consider using QLocalSocket and WINAPI Named Pipe instead
-
Probably off topic, but did you consider using QLocalSocket and WINAPI Named Pipe instead
-
wrote on 20 Feb 2017, 15:24 last edited by 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
-
Check the detailed documentation of QSharedMemory and the setNativeKey. They explain how to achieve communication with non Qt application.
-
wrote on 21 Feb 2017, 10:39 last edited by
@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.
-
@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.
@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?
-
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.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?
-
@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.
-
wrote on 22 Feb 2017, 07:38 last edited by
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.
14/17