3 # Copyright (c) 1997 Graham Barr <gbarr@pobox.com>. All rights reserved.
4 # This program is free software; you can redistribute it and/or
5 # modify it under the same terms as Perl itself.
9 use IPC::SysV qw(IPC_STAT IPC_SET IPC_RMID);
11 use vars qw($VERSION);
17 package IPC::Msg::stat;
19 use Class::Struct qw(struct);
21 struct 'IPC::Msg::stat' => [
38 @_ == 3 || croak 'new IPC::Msg ( KEY , FLAGS )';
41 my $id = msgget($_[0],$_[1]);
56 msgctl($$self,IPC_STAT,$data) or
58 IPC::Msg::stat->new->unpack($data);
69 croak 'Bad arg count' if @_ % 2;
75 while(($key,$val) = each %arg);
78 msgctl($$self,IPC_SET,$ds->pack);
83 (msgctl($$self,IPC_RMID,0), undef $$self)[0];
87 @_ <= 5 && @_ >= 3 or croak '$msg->rcv( BUF, LEN, TYPE, FLAGS )';
90 msgrcv($$self,$buf,$_[1],$_[2] || 0, $_[3] || 0) or
93 ($type,$_[0]) = unpack("L a*",$buf);
98 @_ <= 4 && @_ >= 3 or croak '$msg->snd( TYPE, BUF, FLAGS )';
100 msgsnd($$self,pack("L a*",$_[0],$_[1]), $_[2] || 0);
110 IPC::Msg - SysV Msg IPC object class
114 use IPC::SysV qw(IPC_PRIVATE S_IRWXU S_IRWXG S_IRWXO);
117 $msg = new IPC::Msg(IPC_PRIVATE, S_IRWXU | S_IRWXG | S_IRWXO);
119 $msg->snd(pack("L a*",$msgtype,$msg));
133 =item new ( KEY , FLAGS )
135 Creates a new message queue associated with C<KEY>. A new queue is
142 C<KEY> is equal to C<IPC_PRIVATE>
146 C<KEY> does not already have a message queue
147 associated with it, and C<I<FLAGS> & IPC_CREAT> is true.
151 On creation of a new message queue C<FLAGS> is used to set the
156 Returns the system message queue identifier.
158 =item rcv ( BUF, LEN [, TYPE [, FLAGS ]] )
160 Read a message from the queue. Returns the type of the message read. See
165 Remove and destroy the message queue from the system.
169 =item set ( NAME => VALUE [, NAME => VALUE ...] )
171 C<set> will set the following values of the C<stat> structure associated
172 with the message queue.
176 mode (oly the permission bits)
179 C<set> accepts either a stat object, as returned by the C<stat> method,
180 or a list of I<name>-I<value> pairs.
182 =item snd ( TYPE, MSG [, FLAGS ] )
184 Place a message on the queue with the data from C<MSG> and with type C<TYPE>.
189 Returns an object of type C<IPC::Msg::stat> which is a sub-class of
190 C<Class::Struct>. It provides the following fields. For a description
191 of these fields see you system documentation.
210 L<IPC::SysV> L<Class::Struct>
214 Graham Barr <gbarr@pobox.com>
218 Copyright (c) 1997 Graham Barr. All rights reserved.
219 This program is free software; you can redistribute it and/or modify it
220 under the same terms as Perl itself.