msgxrcv Subroutine
Purpose
Receives an extended message.
Library
Standard C Library (libc.a)
Syntax
#include <sys/msg.h>
int msgxrcv (MessageQueueID, MessagePointer, MessageSize, MessageType, MessageFlag) int MessageQueueID, MessageFlag; size_t MessageSize; struct msgxbuf * MessagePointer; long MessageType;
Description
The msgxrcv subroutine reads a message from the queue specified by the MessageQueueID parameter and stores it into the extended message receive buffer pointed to by the MessagePointer parameter. The current process must have read permission in order to perform this operation. The msgxbuf structure is defined in the sys/msg.h file.
The following limits apply to the message queue:
- Maximum message size is 4 Megabytes.
- Maximum number of messages per queue is 8192.
- Maximum number of message queue IDs is 131072.
- Maximum number of bytes in a queue is 4 Megabytes.
Parameters
Item | Description |
---|---|
MessageQueueID | Specifies the message queue identifier. |
MessagePointer | Specifies a pointer to an extended message receive buffer where a message is stored. |
MessageSize | Specifies the size of the mtext field in bytes. The receive message is truncated to the size specified by the MessageSize parameter if it is larger than the MessageSize parameter and the MSG_NOERROR value is true. The truncated part of the message is lost and no indication of the truncation is given to the calling process. If the message is longer than the number of bytes specified by the MessageSize parameter and the MSG_NOERROR value is not set, the msgxrcv subroutine is unsuccessful and sets the errno global variable to the E2BIG error code. |
MessageType | Specifies the type of message requested as follows:
|
MessageFlag | Specifies a value of 0 or a value constructed by logically
ORing one or more of the following values:
|
Return Values
Upon successful completion, the msgxrcv subroutine returns a value equal to the number of bytes actually stored into the mtext field, and the following actions are taken with respect to the data structure associated with the MessageQueueID parameter:
- The msg_qnum field is decremented by 1.
- The msg_lrpid field is set equal to the process ID of the calling process.
- The msg_rtime field is set equal to the current time.
If the msgxrcv subroutine is unsuccessful, a value of -1 is returned and the errno global variable is set to indicate the error.
Error Codes
The msgxrcv subroutine is unsuccessful if any of the following conditions is true:
Item | Description |
---|---|
EINVAL | The MessageQueueID parameter is not a valid message queue identifier. |
EACCES | The calling process is denied permission for the specified operation. |
EINVAL | The MessageSize parameter is less than 0. |
E2BIG | The mtext field is greater than the MessageSize parameter, and the MSG_NOERROR value is not set. |
ENOMSG | The queue does not contain a message of the desired type and the IPC_NOWAIT value is set. |
EFAULT | The MessagePointer parameter points outside of the process address space. |
EINTR | The msgxrcv subroutine was interrupted by a signal. |
EIDRM | The message queue identifier specified by the MessageQueueID parameter is removed from the system. |