I want a server process to create a segment of shared memory and a client process to be able to access it. I am using the following code.
Server:
void *shared_memory=(void *)0;
shmid=shmget((key_t)998,1024,0666 | IPC_CREAT);
shared_memory=shmat(shmid,(void *)0,0);
Weren't sockets made for this very purpose? To transmit data between processes?
Yes, between processes on different machines. However, there's no need to pay serialization costs if all processes are on the same machine. In some applications this matters.