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
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