mirror of
https://github.com/Hizenberg469/Inter-Process-Communication-IPC-.git
synced 2026-04-19 18:02:24 +03:00
Shared Memory for IPC
This commit is contained in:
26
Shared Memory/reader.c
Normal file
26
Shared Memory/reader.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int
|
||||
read_from_shared_memory(char* mmap_key,
|
||||
char* buffer,
|
||||
unsigned int buff_size,
|
||||
unsigned int bytes_to_read);
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
|
||||
char* key = "/introduction";
|
||||
char read_buffer[128];
|
||||
memset(read_buffer, 0, 128);
|
||||
|
||||
int rc = read_from_shared_memory(key, read_buffer, 128, 128);
|
||||
if (rc < 0) {
|
||||
printf("Error reading from shared memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Data read = %s\n", (char*)read_buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user