Reading messages from a message queueΒΆ

read_msg_queue()

Reading messages from a message queue


SYNTAX

read_msg_queue(msg_id, field_id, mtype, rtype, options)

Read a message from the message queue specified in msg_id into the field field_id.

MSG_id

The return value from the function that created or linked to the message queue.

field_id

An alphanumeric or binary field to receive the message.

mtype

An integer field of sufficient size to receive the message type.

rtype

The required message type. Set to 0 to receive a message of any type.

options

May be GENOPT_WAIT or 0.

If options is GENOPT_WAIT, the function waits until a message of the required type is available.

If options is 0, the function returns immediately if no message of the required type is available.

The function returns the length of the message read, or a negative value indicating an error:

-1

Unexpected error (see sys.Errno)

-2

The message queue has been removed.

-3

No message of the required type is available.


EXAMPLE

!temp MsgQNo,,i4
!temp MsgField,,a255
!temp MsgType,,i4

     MsgQNo = create_msg_queue("msg_abxf", SHM_USE_FTOK))
     if (MsgQNo = -1) {
          error "Error creating message queue"
     }

     read_msg_queue(MsgQNo, MsgField, MsgType, 0, 0)

Message queue functions

create_msgqueue()

Create a message queue

link_msg_queue()

Link to an existing message queue

read_msg_queue()

Read a message from a message queue

write_msg_queue()

Write a message to a message queue

remove_msg_queue()

Remove a message queue