srv_putmsgq

Description

Put a message into a message queue.

Syntax

CS_RETCODE srv_putmsgq(msgqid, msgp, putflags)
SRV_OBJID        msgqid;
CS_VOID            *msgp;
CS_INT              putflags;

Parameters

msgqid

The identifier for the message queue. If you want to reference the message queue by name, call srv_getobjid to look up the name and return the message queue ID.

msgp

A pointer to the message. The message data must be valid until it is received and processed.

putflags

The values for putflags can be OR’d together. Table 3-85 describes each value’s significance:

Table 3-85: Values for putflags (srv_putmsgq)

Value

Description

SRV_M_NOWAIT

When this flag is set, the call to srv_putmsgq returns immediately after the message is placed in the message queue.

SRV_M_WAIT

When SRV_M_WAIT is set, srv_putmsgq does not return until either the message is read or the queue is deleted.

SRV_M_URGENT

If this flag is set, the message is put at the head of the list of messages in the message queue instead of at the end. If more than one urgent message is added to a given queue, the urgent messages will appear at the head of the queue in the order in which they were enqueued.

Returns

Table 3-86: Return values (srv_putmsgq)

Returns

To indicate

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Examples

Example 1

#include  <ospublic.h>

/*
 ** Local Prototype.
 */
CS_RETCODE ex_srv_putmsgq PROTOTYPE((
SRV_OBJID  mqid,
CS_INT     flags
));
/* 
 ** EX_SRV_PUTMSGQ
**
**    Example routine to put a message into a message queue.
**
** Arguments:
**   msgqid    Message queue identifier.
**   putflags  Special instructions for srv_putmsgq.
**
** Returns:
**
**   CS_SUCCEED
**   CS_FAIL
 */
CS_RETCODE     ex_srv_putmsgq(mqid, flags)
SRV_OBJID      mqid;
CS_INT         flags;
{
     CS_CHAR   *msgp;
	msgqp = srv_alloc(20);
     strcpy(msgp, “Hi there”);
     return(srv_putmsgq(mqid, msgp, flags));
}

Usage

See also

srv_createmsgq, srv_deletemsgq, srv_getmsgq, srv_getobjid