IPC Message Queue Help

J

jsahiwal

Perl Guru's
I am not able to find the right options for my message queue. I would
like for the queue to receive messages as soon as they are sent, but
am receiving them after the queue is removed. Seems like a blocking
issue but I am not sure. Posting the two small script I am stuck with.
Would appreciate constructive response.

Sending the message as the incoming argument.

use IPC::Msg;
use IPC::SysV;

$outgoing=$ARGV[0];
$key = 999;
$queue = msgget($key,0) or die $!;
my $type = 1234;

#$queue = new IPC::Msg($key,0);
$string = "This";
#$message = pack(A4,"This");
$message = pack("A*",$outgoing);
print $message;
msgsnd($queue,$message,0);

Receiving Part
#!/usr/bin/perl

use IPC::SysV qw(IPC_PRIVATE S_IRWXU IPC_CREAT);
use IPC::Msg;

my $key = 999;
my $queue = msgget($key,&IPC_CREAT | 0777) or die $!;
my ($buffer,$type);
#for ($i=0; $i < 2; $i++) {
if (defined $queue) {
msgrcv($queue,$buffer,60,0,0);
($type,$string)=unpack("a*",$buffer);
print $buffer ;
}
msgctl($queue,IPC_RMID,0);

I know the queue is made by using ipcs -q .

Thanks
Jack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top