Saturday, May 22, 2010

How to use c++ system calls for send and receive?

Hi,


Does anyone know how to use system calls for sending messages from one process to another instead of using std.cin and std.cout plus redirection ("process1 | process 2" on the command line)? So I can use system.send() for cout, and system.receive() for cin, or something like that.


Thanks a million bunches.

How to use c++ system calls for send and receive?
Have you thought about using shared memory for your interprocess communication? Something like:





int fd = shm_open("my_shared_mem", O_CREAT, ...);


int blah = ftruncate(fd, size_in_bytes);


char * blah_pointer = mmap(offset, size_in_bytes, ...,.., fd);





I forget the exact syntax so the above certainly won't compile but once you get any process to execute something like the above, any following process can open this same piece of shared memory. You can then treat the shared memory (via a pointer) as regular memory by any number of processes.





This may not be the avenue you want to take but it is certainly an alternative.


No comments:

Post a Comment