Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interprocess communication in c/c++

Tags:

c++

c

unix

I'm currently using message queue to pass message between two processes, but I'm hitting 32k maximum size limit. What's the best option. Fragmenting the message and then re-asembling or using TCP/IP sockets to communicate between processes or anything you guys could help me with.

like image 791
kp1 Avatar asked Nov 13 '22 22:11

kp1


1 Answers

Only you can determine the right answer but unix domain sockets are probably your best alternative if you don't want to split/reconstruct the messages. Shared memory would be faster but has the associated synchronization headaches.

If the program(s) reading/writing the queue are single threaded then splitting the messages is easy enough - basically put a byte at the beginning of each segment indicating if it is a new message or a continuation of a previous one. If they are threaded I would bite the bullet and switch to something else.

like image 182
Duck Avatar answered Dec 26 '22 02:12

Duck