Message queue is not blocked in msgsnd

Hi, I am trying to send/receive data by message queue and expecting it to be blocked on send/read for other side (at least this is my understooding ) , I am connecting message between perl<->C , perl is working as expected , but in C msgsnd and msgrcv are not waiting (blocked) untill second side will read/write .
Here is a code I am using :

QueueId = msgget(QueueKey, 0777 | IPC_CREAT | IPC_EXCL );
if ((status=msgsnd(QueueId, &MsgBuf, s.length()+1, 0)) == -1) { /* +1 for '\0' */
fprintf(stderr,"Failing to send a message: \"%s\"...\n",s.c_str()),
msgctl(QueueId, IPC_RMID, NULL);
exit(-1);
};
msgrcv(QueueId, &MsgBuf, sizeof(MsgBuf.mtext), 0, 0);

Appreciate any help

Check the return value of everything and whenever it's not what you expected, perror("something happened");. What's the value of QueueID?

QueueID=1409024
The return statuses are : MSGSND:0 MSGRCV: 16
I am expecting this process stalled on msgsnd ... Correct ? But it doesn't ...

Well, it's receiving a message. Check the contents, see what it received.

Let me to describe a problem more precised :
I am expectin to open the message in other process in perl ,it should get a data from C->msgsnd and reply back to C-msgrcv.
I am expecting from C->msgsnd to be blocked untill perl will make msgrcv
and C->msgrcv to be blocked untill perl side will execute Perl->msgsnd .
However I don't run Perl at all and C->msgsnd should be stacked forever ...
However it execute msgsnd and msgread with previously send data without waiting ...

Interesting, now I see why msgrcv can selectively ignore message types.

Have them send and receive different message types, blocking their own.

msg->mtype=1; // Send a type-1 message.
msgsnd(msqid, msg, msg_size, 0);
msgrcv(msqid, msg, msg_size, 1, MSG_EXCEPT); // Ignore type-1 messages

Waw it is working , THANKS A LOT
(I spend half day on this stupid thing ):rolleyes: