Create a message queue.
CS_RETCODE srv_createmsgq(msgqnamep, msgq_namelen,
msgqidp)
CS_CHAR *msgqnamep; CS_INT msgqname_len; SRV_OBJID *msgqidp;
A pointer to the name of the queue to create. It is an error to attempt to create a queue that al&ready exists.
The length of the name in *msgqnamep. If the name is null terminated, an application can set msgqname_len to CS_NULLTERM. A message queue can be up to SRV_MAXNAME characters long.
Open Server returns the ID of the newly created message queue in *msgqidp.
Returns: |
To indicate: |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#include <ospublic.h>
/*
** Local Prototype
*/
CS_RETCODE ex_srv_createmsgq PROTOTYPE((
SRV_OBJID *msgqp,
CS_CHAR *msgqnm
));
/*
** EX_SRV_CREATEMSGQ
**
** Example routine to create an Open Server message queue
** using srv_createmsgq.
**
** Arguments:
** msgqp Return pointer to the created message queue
** identifier.
** msgqn Null terminated name for the created queue.
**
** Returns:
** CS_SUCCEED Message queue with given name successfully
created.
** CS_FAIL An error was detected.
*/
CS_RETCODE ex_srv_createmsgq(msgqp, msgqnm)
SRV_OBJID *msgqp;
CS_CHAR *msgqnm;
{
/* Check parameters. */
if ((CS_INT)strlen(msgqnm) > SRV_MAXNAME)
{
return(CS_FAIL);
}
/* Create the message queue. */
if (srv_createmsgq(msgqnm, (CS_INT)CS_NULLTERM, msgqp) !=
CS_SUCCEED)
{
return(CS_FAIL);
}
return(CS_SUCCEED);
}
When creating a message queue, an application must assign it a name. Once a message queue has been created, an application can reference it either by name or by ID.
Given the ID of a message queue, use srv_getobjname to look up the name.
SRV_OBJID is defined as a CS_INT.
The SRV_S_NUMMSGQUEUES server property determines the number of message queues available to an Open Server application. Refer to “Server properties”.
The SRV_S_MSGPOOL server property determines the number of messages available to an Open Server application at runtime. Refer to “Server properties”.