Module posix.sys.msg
Sys V Message Queue Operations.
Where supported by the underlying system, functions to send and receive
interprocess messages. If the module loads successfully, but there is
no system support, then posix.sys.msg.version
will be set, but the
unsupported APIs wil be nil
.
Functions
msgget (key[, flags=0]) | Get a message queue identifier |
msgrcv (id, size, type[, flags=0]) | Receive message from a message queue |
msgsnd (id, type, message[, flags=0]) | Send message to a message queue |
Constants
posix.sys.msg | Message constants. |
Functions
- msgget (key[, flags=0])
-
Get a message queue identifier
Parameters:
- key
int
message queue id, or
IPC_PRIVATE
for a new queue - flags
int
bitwise OR of zero or more from
IPC_CREAT
andIPC_EXCL
, and access permissionsS_IRUSR
,S_IWUSR
,S_IRGRP
,S_IWGRP
,S_IROTH
andS_IWOTH
(from posix.sys.stat) (default 0)
Returns:
-
int
message queue identifier, if successful
Or
- nil
- string error message
- int errnum
See also:
- key
int
message queue id, or
- msgrcv (id, size, type[, flags=0])
-
Receive message from a message queue
Parameters:
- id int message queue identifier returned by msgget
- size int maximum message size
- type int message type (optional, default - 0)
- flags
int
bitwise OR of zero or more of
IPC_NOWAIT
,MSG_EXCEPT
andMSG_NOERROR
(default 0)
Returns:
Or
- nil
- string error message
- int errnum
See also:
- msgsnd (id, type, message[, flags=0])
-
Send message to a message queue
Parameters:
- id int message queue identifier returned by msgget
- type int arbitrary message type
- message string content
- flags
int
optionally
IPC_NOWAIT
(default 0)
Returns:
-
int
0, if successful
Or
- nil
- string error message
- int errnum
See also:
Constants
- posix.sys.msg
-
Message constants.
Any constants not available in the underlying system will be
nil
valued.Fields:
- IPC_CREAT int create entry if key does not exist
- IPC_EXCL int fail if key exists
- IPC_PRIVATE int private key
- IPC_NOWAIT int error if request must wait
- MSG_EXCEPT int read messages with differing type
- MSG_NOERROR int truncate received message rather than erroring
Usage:
-- Print msg constants supported on this host. for name, value in pairs (require "posix.sys.msg") do if type (value) == "number" then print (name, value) end end