# Copyright (c) 1997 Graham Barr <gbarr@pobox.com>. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
use IPC
::SysV
qw(IPC_STAT IPC_SET IPC_RMID);
$VERSION = eval $VERSION;
use Class::Struct qw(struct);
struct
'IPC::Msg::stat' => [
@_ == 3 || croak
'new IPC::Msg ( KEY , FLAGS )';
my $id = msgget($_[0],$_[1]);
msgctl($$self,IPC_STAT
,$data) or
IPC
::Msg
::stat->new->unpack($data);
croak
'Bad arg count' if @_ % 2;
while(($key,$val) = each %arg);
msgctl($$self,IPC_SET
,$ds->pack);
(msgctl($$self,IPC_RMID
,0), undef $$self)[0];
@_ <= 5 && @_ >= 3 or croak
'$msg->rcv( BUF, LEN, TYPE, FLAGS )';
msgrcv($$self,$buf,$_[1],$_[2] || 0, $_[3] || 0) or
($type,$_[0]) = unpack("l! a*",$buf);
@_ <= 4 && @_ >= 3 or croak
'$msg->snd( TYPE, BUF, FLAGS )';
msgsnd($$self,pack("l! a*",$_[0],$_[1]), $_[2] || 0);
IPC::Msg - SysV Msg IPC object class
use IPC::SysV qw(IPC_PRIVATE S_IRWXU);
$msg = new IPC::Msg(IPC_PRIVATE, S_IRWXU);
$msg->snd(pack("l! a*",$msgtype,$msg));
A class providing an object based interface to SysV IPC message queues.
=item new ( KEY , FLAGS )
Creates a new message queue associated with C<KEY>. A new queue is
C<KEY> is equal to C<IPC_PRIVATE>
C<KEY> does not already have a message queue
associated with it, and C<I<FLAGS> & IPC_CREAT> is true.
On creation of a new message queue C<FLAGS> is used to set the
Returns the system message queue identifier.
=item rcv ( BUF, LEN [, TYPE [, FLAGS ]] )
Read a message from the queue. Returns the type of the message read.
See L<msgrcv>. The BUF becomes tainted.
Remove and destroy the message queue from the system.
=item set ( NAME => VALUE [, NAME => VALUE ...] )
C<set> will set the following values of the C<stat> structure associated
mode (oly the permission bits)
C<set> accepts either a stat object, as returned by the C<stat> method,
or a list of I<name>-I<value> pairs.
=item snd ( TYPE, MSG [, FLAGS ] )
Place a message on the queue with the data from C<MSG> and with type C<TYPE>.
Returns an object of type C<IPC::Msg::stat> which is a sub-class of
C<Class::Struct>. It provides the following fields. For a description
of these fields see you system documentation.
L<IPC::SysV> L<Class::Struct>
Graham Barr <gbarr@pobox.com>
Copyright (c) 1997 Graham Barr. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.