Syntax | #include <sys/msg.h> int msgrcv(int msqid, void *msgp, size_t msgsz, long int msgtyp, int msgflg); | |
Description |
msgp points to a user-defined buffer that must contain first a field of type struct mymsg { long int mtype; /* Message type */ char mtext[1]; /* Message text */ } The structure member The structure member msgsz specifies the size in bytes of msgtyp specifies the type of message requested as follows:
msgflg specifies the action to be taken if a message of the desired type is not on the queue. The following actions are possible:
Upon successful completion, the following actions are taken with respect to the data structure associated with msqid:
If threads are used, then the function affects the process or a thread in the following manner: The msgflg parameter refers to the calling thread. | |
Return val. | number of bytes placed in | |
if successful. | ||
-1 | if an error occurs. | |
Errors | msgrcv() will fail if: | |
| The value of | |
| Operation permission is denied to the calling process. | |
Extension | ||
| msgp points to an invalid address. (End) | |
| The message queue identifier msqid is removed from the system. | |
|
| |
| msqid is not a valid message queue identifier or the value of msgsz is less than 0. | |
| The queue does not contain a message of the desired type and (msgtyp | |
Notes | msgp should be converted to type The IEEE 1003.4 Standards Committee is developing alternative interfaces for interprocess communication. Application developers who need to use interprocess communication (IPC) should design their applications so that modules using the IPC routines described here can be easily modified at a later date. | |
See also |
|