Creating a message queue

create_msg_queue()

Create a message queue


SYNTAX

create_msg_queue(queue_name, options)

Create a message queue. Message queues enable Sculptor programs to communicate with C programs on UNIX and Linux.

queue_name

The name of the message queue. This is an alphanumeric value; valid characters are A-Z, a-z, 0-9 and the underscore ( _ ). Sculptor converts the name to a system key that is a 4-byte integer on most systems.

options

Set to 0 or to SHM_USE_FTOK.

If options = 0, Sculptor creates the system key from a simple hash of queue_name.

If options = SHM_USE_FTOK, the C library function ftok() is called to create the key. In this case the first character of queue_name is used as the id char for ftok(), and the remaining text as the pathname of an existing file that must be accessible to the process. See the UNIX documentation of ftok() for more details.

The return value from the function must be stored in an i4 type field. If the function was successful, the return value is used to identify this message queue in calls to other functions.

A return value of -1 means that the function failed. Normal reasons for failure are:

1

Another program has already created the message queue.

2

The system has run out of message queues. This is unlikely.

When a message queue is no longer needed it must be explicitly removed by calling remove_msg_queue(). If not removed, a message queue can survive in the system even after all programs using it have exited.


EXAMPLE

!temp MsgQNo,,i4

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

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


RELATED TOPICS

create_shared_memory()