Open zeroRains opened 4 months ago
I try to send a std::string from client to server. I modify the code in the rpc.cpp
I modify the struct Message,
struct Message { uint64_t count; uint64_t timestamp; uint8_t *data; std::string code; };
function callback(),
bool callback(const shm::memory::Memblock &req, shm::memory::Memblock *resp) { auto *msg = reinterpret_cast<Message *>(req.ptr); auto lag = shm::current_time() - msg->timestamp; std::cout << current_count << ", " << msg->count <<" "<<msg->code << "\n"; .... }
and function client_loop().
void client_loop(int seconds, int vector_size) { ... auto *rawptr = malloc(vector_size); std::memset(rawptr, 255, vector_size); Message *msg = reinterpret_cast<Message *>(rawptr); msg->count = 0; msg->code = "hello world!"; ... }
But it got a segmentation fault error when I std::cout the msg->code.
I try to send a std::string from client to server. I modify the code in the rpc.cpp
I modify the struct Message,
function callback(),
and function client_loop().
But it got a segmentation fault error when I std::cout the msg->code.