Reputation: 44405
In PHP I try to send a message through IPC, and to immediately check if the message is in the queue. Here is a test code:
$rQueue = msg_get_queue(12345, 0660);
msg_send($rQueue, 0, "test", FALSE, FALSE);
print_r(msg_stat_queue($rQueue));
which prints out the statistics from the given queue, indicating msg_qnum=0
, i.e. no messages are in the queue. The expected behavior is to see at least one message in the queue instead. Where is the problem?
Upvotes: 0
Views: 498
Reputation: 925
Looking in the manual it says:
bool msg_send ( resource $queue , int $msgtype , mixed $message [, bool $serialize = true [, bool $blocking = true [, int &$errorcode ]]] )
msg_send() sends a message of type msgtype (which MUST be greater than 0) to the message queue specified by queue.
So changing the second parameter from 0 to 1 solves the problem.
Please also have a look at the error_reporting() function. When I run your code, PHP indicated the problem with a Warning:
PHP Warning: msg_send(): msgsnd failed: Invalid argument
Upvotes: 1