An example that shows how to set up a client to receive shared memory segments from the server. Works only on Linux.
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <glib.h>
#define BLOCK_SIZE (1024 * 1024)
int
main(int argc, const char *argv[])
{
void *addr;
if (argc < 2) {
fprintf(stderr, "Usage: shm-client <server socket URI>\n");
return (1);
}
if (client == NULL) {
fprintf(stderr, "cannot connect: %s\n", strerror(errno));
return (1);
}
shmem = rpc_shmem_create(BLOCK_SIZE);
addr = rpc_shmem_map(shmem);
memset(addr, 'A', rpc_shmem_get_size(shmem));
printf("memory before :%.*s\n", 16, addr);
shmem);
printf("memory after :%.*s\n", 16, addr);
rpc_shmem_unmap(shmem, addr);
return (0);
}