Sun Microsystems, Inc.
spacerspacer
spacer   www.sun.com docs.sun.com | | |  
spacer
black dot
   
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z
    
 
Realtime Library Functionsmq_send(3RT)


NAME

 mq_send - send a message to a message queue

SYNOPSIS

 
cc [ flag... ] file... -lrt [ library... ]
#include <mqueue.h> 
int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio);

DESCRIPTION

 

The mq_send() function adds the message pointed to by the argument msg_ptr to the message queue specified by mqdes. The msg_len argument specifies the length of the message in bytes pointed to by msg_ptr. The value of msg_len is less than or equal to the mq_msgsize attribute of the message queue, or mq_send() fails.

If the specified message queue is not full, mq_send() behaves as if the message is inserted into the message queue at the position indicated by the msg_prio argument. A message with a larger numeric value of msg_prio is inserted before messages with lower values of msg_prio. A message will be inserted after other messages in the queue, if any, with equal msg_prio. The value of msg_prio must be greater than zero and less than or equal to MQ_PRIO_MAX.

If the specified message queue is full and O_NONBLOCK is not set in the message queue description associated with mqdes (see mq_open(3RT) and mq_setattr(3RT)), mq_send() blocks until space becomes available to enqueue the message, or until mq_send() is interrupted by a signal. If more than one thread is waiting to send when space becomes available in the message queue, then the thread of the highest priority which has been waiting the longest is unblocked to send its message. Otherwise, it is unspecified which waiting thread is unblocked. If the specified message queue is full and O_NONBLOCK is set in the message queue description associated with mqdes, the message is not queued and mq_send() returns an error.

RETURN VALUES

 

Upon successful completion, mq_send() returns 0; otherwise, no message is enqueued, the function returns -1, and errno is set to indicate the error.

ERRORS

 

The mq_send() function will fail if:

EAGAIN
The O_NONBLOCK flag is set in the message queue description associated with mqdes, and the specified message queue is full.
EBADF
The mqdes argument is not a valid message queue descriptor open for writing.
EINTR
A signal interrupted the call to mq_send()
EINVAL
The value of msg_prio was outside the valid range.
EMSGSIZE
The specified message length, msg_len, exceeds the message size attribute of the message queue.
ENOSYS
The mq_send() function is not supported by the system.

ATTRIBUTES

 

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPEATTRIBUTE VALUE
MT-LevelMT-Safe

SEE ALSO

 

mq_open(3RT), mq_receive(3RT), mq_setattr(3RT), sysconf(3C), attributes(5), mqueue(3HEAD)

NOTES

 

Solaris 2.6 was the first release to support the Asynchronous Input and Output option. Prior to this release, this function always returned -1 and set errno to ENOSYS.


SunOS 5.9Go To TopLast Changed 22 Jun 1998

 
      
      
Copyright 2002 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.