PHP message queue with perl?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


Message queue problem. Perl program creates a message queue and send a
message to it. PHP program is to receive the message. Simple. But PHP's
msg_receive() is getting corrupted message. Can anyone tell me what is
wrong in the code?

Perl code

#!/usr/bin/perl -w

use constant S_IRWXA => 0666;
use constant IPC_CREATE => 01000;

$key = 123456789;
$msgid = msgget($key, S_IRWXA | IPC_CREATE);

$type = 1;
$msg = "Hi PHP";
$data = pack("l! a*", $type, $msg);
msgsnd($msgid, $data, length($data) );

PHP code

$key = 123456789;
$qu = msg_get_queue($key);

$type = 1;
print "\nWaiting for message ...";
msg_receive ($qu, $type, $atyp, 1024, $data);
print "\nRecv data: " . $data;

PHP code generates error like below -

Warning:  msg_receive(): message corrupted in
<b>/var/www/embarque/test/intourist/msgq.php</b> on line <b>7</b>

Thanks in advance


Site Timeline