Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

msg_receive(3) [php man page]

MSG_RECEIVE(3)								 1							    MSG_RECEIVE(3)

msg_receive - Receive a message from a message queue

SYNOPSIS
bool msg_receive (resource $queue, int $desiredmsgtype, int &$msgtype, int $maxsize, mixed &$message, [bool $unserialize = true], [int $flags], [int &$errorcode]) DESCRIPTION
msg_receive(3) will receive the first message from the specified $queue of the type specified by $desiredmsgtype. PARAMETERS
o $queue - o $desiredmsgtype - If $desiredmsgtype is 0, the message from the front of the queue is returned. If $desiredmsgtype is greater than 0, then the first message of that type is returned. If $desiredmsgtype is less than 0, the first message on the queue with the lowest type less than or equal to the absolute value of $desiredmsgtype will be read. If no messages match the criteria, your script will wait until a suitable message arrives on the queue. You can prevent the script from blocking by specifying MSG_IPC_NOWAIT in the $flags parameter. o $msgtype - The type of the message that was received will be stored in this parameter. o $maxsize - The maximum size of message to be accepted is specified by the $maxsize; if the message in the queue is larger than this size the function will fail (unless you set $flags as described below). o $message - The received message will be stored in $message, unless there were errors receiving the message. o $unserialize - If set to TRUE, the message is treated as though it was serialized using the same mechanism as the session module. The message will be unserialized and then returned to your script. This allows you to easily receive arrays or complex object structures from other PHP scripts, or if you are using the WDDX serializer, from any WDDX compatible source. If $unserialize is FALSE, the mes- sage will be returned as a binary-safe string. o $flags - The optional $flags allows you to pass flags to the low-level msgrcv system call. It defaults to 0, but you may specify one or more of the following values (by adding or ORing them together). Flag values for msg_receive +---------------+---------------------------------------------------+ | | | |MSG_IPC_NOWAIT | | | | | | | If there are no messages of the $desiredmsgtype, | | | return immediately and do not wait. The function | | | will fail and return an integer value correspond- | | | ing to MSG_ENOMSG. | | | | | | | | MSG_EXCEPT | | | | | | | Using this flag in combination with a $desiredms- | | | gtype greater than 0 will cause the function to | | | receive the first message that is not equal to | | | $desiredmsgtype. | | | | | | | | MSG_NOERROR | | | | | | | If the message is longer than $maxsize, setting | | | this flag will truncate the message to $maxsize | | | and will not signal an error. | | | | +---------------+---------------------------------------------------+ o $errorcode - If the function fails, the optional $errorcode will be set to the value of the system errno variable. RETURN VALUES
Returns TRUE on success or FALSE on failure. Upon successful completion the message queue data structure is updated as follows: msg_lrpid is set to the process-ID of the calling process, msg_qnum is decremented by 1 and msg_rtime is set to the current time. SEE ALSO
msg_remove_queue(3), msg_send(3), msg_stat_queue(3), msg_set_queue(3). PHP Documentation Group MSG_RECEIVE(3)

Check Out this Related Man Page

mq_notify(3C)						   Standard C Library Functions 					     mq_notify(3C)

NAME
mq_notify - notify process (or thread) that a message is available on a queue SYNOPSIS
#include <mqueue.h> int mq_notify(mqd_t mqdes, const struct sigevent *notification); DESCRIPTION
The mq_notify() function provides an asynchronous mechanism for processes to receive notice that messages are available in a message queue, rather than synchronously blocking (waiting) in mq_receive(3C). If notification is not NULL, this function registers the calling process to be notified of message arrival at an empty message queue asso- ciated with the message queue descriptor, mqdes. The notification specified by notification will be sent to the process when the message queue transitions from empty to non-empty. See signal.h(3HEAD). At any time, only one process may be registered for notification by a spe- cific message queue. If the calling process or any other process has already registered for notification of message arrival at the speci- fied message queue, subsequent attempts to register for that message queue will fail. If notification is NULL and the process is currently registered for notification by the specified message queue, the existing registration is removed. The message queue is then available for future registration. When the notification is sent to the registered process, its registration is removed. The message queue is then available for registration. If a process has registered for notification of message arrival at a message queue and some processes is blocked in mq_receive(3C) waiting to receive a message when a message arrives at the queue, the arriving message will be received by the appropriate mq_receive(3C), and no notification will be sent to the registered process. The resulting behavior is as if the message queue remains empty, and this notification will not be sent until the next arrival of a message at this queue. Any notification registration is removed if the calling process either closes the message queue or exits. RETURN VALUES
Upon successful completion, mq_notify() returns 0; otherwise, it returns -1 and sets errno to indicate the error. ERRORS
The mq_notify() function will fail if: EBADF The mqdes argument is not a valid message queue descriptor. EBUSY A process is already registered for notification by the message queue. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ |Standard |See standards(5). | +-----------------------------+-----------------------------+ SEE ALSO
mq_close(3C), mq_open(3C), mq_receive(3C), mq_send(3C), mqueue.h(3HEAD), siginfo.h(3HEAD), signal.h(3HEAD), attributes(5), standards(5) SunOS 5.11 5 Feb 2008 mq_notify(3C)
Man Page