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);
15 $VERSION = eval $VERSION;
18 package IPC::Msg::stat;
20 use Class::Struct qw(struct);
22 struct 'IPC::Msg::stat' => [
39 @_ == 3 || croak 'new IPC::Msg ( KEY , FLAGS )';
42 my $id = msgget($_[0],$_[1]);
57 msgctl($$self,IPC_STAT,$data) or
59 IPC::Msg::stat->new->unpack($data);
70 croak 'Bad arg count' if @_ % 2;
76 while(($key,$val) = each %arg);
79 msgctl($$self,IPC_SET,$ds->pack);
84 (msgctl($$self,IPC_RMID,0), undef $$self)[0];
88 @_ <= 5 && @_ >= 3 or croak '$msg->rcv( BUF, LEN, TYPE, FLAGS )';
91 msgrcv($$self,$buf,$_[1],$_[2] || 0, $_[3] || 0) or
94 ($type,$_[0]) = unpack("l! a*",$buf);
99 @_ <= 4 && @_ >= 3 or croak '$msg->snd( TYPE, BUF, FLAGS )';
101 msgsnd($$self,pack("l! a*",$_[0],$_[1]), $_[2] || 0);
111 IPC::Msg - SysV Msg IPC object class
115 use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR);
118 $msg = new IPC::Msg(IPC_PRIVATE, S_IRUSR | S_IWUSR);
120 $msg->snd(pack("l! a*",$msgtype,$msg));
130 A class providing an object based interface to SysV IPC message queues.
136 =item new ( KEY , FLAGS )
138 Creates a new message queue associated with C<KEY>. A new queue is
145 C<KEY> is equal to C<IPC_PRIVATE>
149 C<KEY> does not already have a message queue
150 associated with it, and C<I<FLAGS> & IPC_CREAT> is true.
154 On creation of a new message queue C<FLAGS> is used to set the
155 permissions. Be careful not to set any flags that the Sys V
156 IPC implementation does not allow: in some systems setting
157 execute bits makes the operations fail.
161 Returns the system message queue identifier.
163 =item rcv ( BUF, LEN [, TYPE [, FLAGS ]] )
165 Read a message from the queue. Returns the type of the message read.
166 See L<msgrcv>. The BUF becomes tainted.
170 Remove and destroy the message queue from the system.
174 =item set ( NAME => VALUE [, NAME => VALUE ...] )
176 C<set> will set the following values of the C<stat> structure associated
177 with the message queue.
181 mode (oly the permission bits)
184 C<set> accepts either a stat object, as returned by the C<stat> method,
185 or a list of I<name>-I<value> pairs.
187 =item snd ( TYPE, MSG [, FLAGS ] )
189 Place a message on the queue with the data from C<MSG> and with type C<TYPE>.
194 Returns an object of type C<IPC::Msg::stat> which is a sub-class of
195 C<Class::Struct>. It provides the following fields. For a description
196 of these fields see you system documentation.
215 L<IPC::SysV> L<Class::Struct>
219 Graham Barr <gbarr@pobox.com>
223 Copyright (c) 1997 Graham Barr. All rights reserved.
224 This program is free software; you can redistribute it and/or modify it
225 under the same terms as Perl itself.