The msgsnd/msgrcv function describes how to send and receive messages in a message queue. To send a message, the calling process must have the write power when writing the message queue. You must have the read capability when receiving messages. Int round (INT msqid, const void * msgp, size_t msgsz, int msgflg); Round msgrcv (INT msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg ); when using msgsnd, you must obtain a msgid. Msgidea is obtained by using the first parameter of the msgget () function int msgget (key_t key, int msgflg) function is the key of the Message Queue object ), the function associates it with an existing message queue.
The key words of the column object are compared to determine whether the message queue object has been created. The specific operations performed by the function are as follows:
The second parameter is controlled by msgflg. It can take down the following values:
Ipc_creat:
If the message queue object does not exist, create it. Otherwise, open it;
Ipc_excl:
It is used with ipc_creat (connected by "|"). If the message object does not exist, it is created. Otherwise,
Error and return.
If the ipc_creat flag is used separately, the msgget () function returns either an existing Message Queue object
Or return the identifier of a newly created Message Queue object. If ipc_creat and ipc_excl
When the message is used together, msgget () returns the identifier of a new message object, or-1 if the message queue
The object already exists. The ipc_excl mark does not have much significance, but it can be used with the ipc_creat mark.
To ensure that the obtained Message Queue object is a newly created object instead of an existing object.