Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mq_receive.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mq_receive.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mq_receive.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mq_receive.html on line 8
Receive a message from a queue
#include <mqueue.h>
ssize_t mq_receive( mqd_t mqdes,
char* msg_ptr,
size_t msg_len,
unsigned int* msg_prio );
- mqdes
- The message-queue descriptor, returned by
mq_open(),
of the message queue that you want to get a message from.
- msg_ptr
- A pointer to a buffer where the function can store the message received.
- msg_len
- The message size of the given queue.
- msg_prio
- NULL, or a pointer to a location where the function can
store the priority of the message received.
The mq_receive() function is used to receive the oldest of
the highest priority messages in the queue specified by
mqdes. The priority of the message received is put in
the location pointed to by msg_prio, the data itself in the
location pointed to by msg_ptr, and the size received is
returned.
|
Neutrino supports two implementations of message queues:
a traditional implementation, and an alternate one that uses
asynchronous messages.
For more information, see the entry for
mq and mqueue
in the Utilities Reference. |
If you call mq_receive() with a msg_len that's
less than the mq_msgsize of the specified queue,
then mq_receive() returns an error and sets errno
to EMSGSIZE.
If there are no messages on the queue specified, and
O_NONBLOCK wasn't set
(in the oflag argument to mq_open()),
then the mq_receive() call
blocks. If multiple mq_receive() calls are blocked on
a single queue, then they're unblocked in FIFO order as messages
arrive.
In the traditional (mqueue) implementation, calling
read()
with mqdes is analogous to
calling mq_receive() with a NULL
msg_prio.
The size of the message removed from the queue. If the call fails, -1 is
returned as the size, no message is removed from the queue, and
errno
is set.
- EAGAIN
- The O_NONBLOCK flag was
set and there are no messages currently on the specified queue.
- EBADF
- The mqdes argument doesn't represent a valid queue open for
reading.
- EINTR
- The operation was interrupted by a signal.
- EINVAL
- The msg_ptr argument isn't a valid pointer.
- EMSGSIZE
- The given msg_len is
less than the mq_msgsize for the given queue
or the
given msg_len is too short for the message that
would have been received.
POSIX 1003.1 MSG
Safety: | |
Cancellation point |
Yes |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
mq_close(),
mq_open(),
mq_send(),
mq_timedreceive(),
read()
mq, mqueue
in the Utilities Reference
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mq_receive.html on line 226
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mq_receive.html on line 226