msgsnd()

This is used for sending or delivering a message to the queue. Here is its syntax:

 int msgsnd ( int msqid, struct msgbuf *msgstruc, int msgsize, int flag );

Here, we have to address the following:

If this is executed successfully, the function returns 0, otherwise it returns -1.

We will now begin with the first part of this recipe: writing a message into the queue.