I'm trying to connect c++(server) and python(client) using socket and want to send share data using shared memory also message sending. Data in the formate of CSV file which is created by c++.
-
It's not clear what is the problem you have. – jordanvrtanoski Mar 03 '21 at 10:45
-
2Are you sure that shared memory is what you want? Perhaps you should look at serialization instead? – Ted Lyngmo Mar 03 '21 at 10:52
-
Did you notice that you have answers to your question? It would be customary, and appreciated, if you gave some feedback. – Mark Setchell Mar 10 '21 at 11:30
2 Answers
You can do that very simply, fast and even across networks with Redis, which has bindings for C/C++. Python, Ruby, bash
and so on. It is a very fast, light-weight, "in-memory" data-structure server that can serve integers, strings, lists, queues, FIFOs, sets, atomic integers, hashes, ordered sets etc. It can also run on Linux, macOS and Windows, in client or server form, without worrying about the differences in shared memory and sockets between those platforms.
The bash
CLI (command-line interface) makes it very simple to debug what's going on in your code and also to inject test data.
So, for example, you could use a Redis hash to represent your data - I am just using the Terminal here to connect to the localhost, but it could be on any machine:
redis-cli -h 127.0.0.1
127.0.0.1:6379> hmset day:1 1 s 2 e 3 i 4 r
OK
127.0.0.1:6379> hmset day:5 1 e 2 i 3 r 4 r
OK
127.0.0.1:6379> hgetall day:5
1) "1"
2) "e"
3) "2"
4) "i"
5) "3"
6) "r"
7) "4"
8) "r"
127.0.0.1:6379> hmget day:5 4
1) "r"
Non-interactive version:
redis-cli --raw hmget day:5 2
i
Retrieve the day1
values with Python:
#!/usr/bin/env python3
import redis
# Redis connection
r = redis.Redis(host='localhost')
# Retrieve our hash from Redis
day1 = r.hgetall("day:1")
print(day1)
Sample Output
{b'1': b's', b'2': b'e', b'3': b'i', b'4': b'r'}
Examples of C/C++ and Python bindings here.

- 191,897
- 31
- 273
- 432
If you are on Windows you can try Memurai. It's a really fast-data store. It works like a charm

- 242
- 1
- 4