0

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

Networkx
  • 21
  • 4

2 Answers2

0

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.

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
0

If you are on Windows you can try Memurai. It's a really fast-data store. It works like a charm

SimonFarron
  • 242
  • 1
  • 4