221 lines
11 KiB
HTML
221 lines
11 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>mq_send</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="mq_send"></a> <a name="tag_03_387"></a><!-- mq_send -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_387_01"></a>NAME</h4>
|
|
|
|
<blockquote>mq_send, mq_timedsend - send a message to a message queue (<b>REALTIME</b>)</blockquote>
|
|
|
|
<h4><a name="tag_03_387_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('MSG')">MSG</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> #include <<a href="../basedefs/mqueue.h.html">mqueue.h</a>><br>
|
|
<br>
|
|
int mq_send(mqd_t</tt> <i>mqdes</i><tt>, const char *</tt><i>msg_ptr</i><tt>, size_t</tt> <i>msg_len</i><tt>,<br>
|
|
unsigned</tt> <i>msg_prio</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]"
|
|
border="0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
<br>
|
|
</tt>
|
|
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('MSG TMO')">MSG TMO</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"><br>
|
|
#include <<a href="../basedefs/mqueue.h.html">mqueue.h</a>><br>
|
|
#include <<a href="../basedefs/time.h.html">time.h</a>><br>
|
|
int mq_timedsend(mqd_t</tt> <i>mqdes</i><tt>, const char *</tt><i>msg_ptr</i><tt>, size_t</tt> <i>msg_len</i><tt>,<br>
|
|
unsigned</tt> <i>msg_prio</i><tt>, const struct timespec *</tt><i>abs_timeout</i><tt>); <img
|
|
src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_03_387_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>mq_send</i>() function shall add the message pointed to by the argument <i>msg_ptr</i> to the message queue specified by
|
|
<i>mqdes</i>. The <i>msg_len</i> argument specifies the length of the message, in bytes, pointed to by <i>msg_ptr</i>. The value of
|
|
<i>msg_len</i> shall be less than or equal to the <i>mq_msgsize</i> attribute of the message queue, or <i>mq_send</i>() shall
|
|
fail.</p>
|
|
|
|
<p>If the specified message queue is not full, <i>mq_send</i>() shall behave as if the message is inserted into the message queue
|
|
at the position indicated by the <i>msg_prio</i> argument. A message with a larger numeric value of <i>msg_prio</i> shall be
|
|
inserted before messages with lower values of <i>msg_prio</i>. A message shall be inserted after other messages in the queue, if
|
|
any, with equal <i>msg_prio</i>. The value of <i>msg_prio</i> shall be less than {MQ_PRIO_MAX}.</p>
|
|
|
|
<p>If the specified message queue is full and O_NONBLOCK is not set in the message queue description associated with <i>mqdes</i>,
|
|
<i>mq_send</i>() shall block until space becomes available to enqueue the message, or until <i>mq_send</i>() is interrupted by a
|
|
signal. If more than one thread is waiting to send when space becomes available in the message queue and the Priority Scheduling
|
|
option is supported, then the thread of the highest priority that has been waiting the longest shall be 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 <i>mqdes</i>, the message shall not be queued and <i>mq_send</i>() shall
|
|
return an error.</p>
|
|
|
|
<p><sup>[<a href="javascript:open_code('TMO')">TMO</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The <i>mq_timedsend</i>() function shall add a message to the message queue specified by <i>mqdes</i> in the manner defined for the
|
|
<i>mq_send</i>() function. However, if the specified message queue is full and O_NONBLOCK is not set in the message queue
|
|
description associated with <i>mqdes</i>, the wait for sufficient room in the queue shall be terminated when the specified timeout
|
|
expires. If O_NONBLOCK is set in the message queue description, this function shall be equivalent to <i>mq_send</i>().</p>
|
|
|
|
<p>The timeout shall expire when the absolute time specified by <i>abs_timeout</i> passes, as measured by the clock on which
|
|
timeouts are based (that is, when the value of that clock equals or exceeds <i>abs_timeout</i>), or if the absolute time specified
|
|
by <i>abs_timeout</i> has already been passed at the time of the call. <img src="../images/opt-end.gif" alt="[Option End]" border=
|
|
"0"></p>
|
|
|
|
<p><sup>[<a href="javascript:open_code('TMO TMR')">TMO TMR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"
|
|
border="0"> If the Timers option is supported, the timeout shall be based on the CLOCK_REALTIME clock; if the Timers option is not
|
|
supported, the timeout shall be based on the system clock as returned by the <a href="../functions/time.html"><i>time</i>()</a>
|
|
function. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
|
|
|
|
<p><sup>[<a href="javascript:open_code('TMO')">TMO</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The resolution of the timeout shall be the resolution of the clock on which it is based. The <i>timespec</i> argument is defined in
|
|
the <a href="../basedefs/time.h.html"><i><time.h></i></a> header.</p>
|
|
|
|
<p>Under no circumstance shall the operation fail with a timeout if there is sufficient room in the queue to add the message
|
|
immediately. The validity of the <i>abs_timeout</i> parameter need not be checked when there is sufficient room in the queue. <img
|
|
src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_387_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, the <i>mq_send</i>() <sup>[<a href="javascript:open_code('TMO')">TMO</a>]</sup> <img src=
|
|
"../images/opt-start.gif" alt="[Option Start]" border="0"> and <i>mq_timedsend</i>() <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"> functions shall return a value of zero. Otherwise, no message shall be enqueued, the functions shall
|
|
return -1, and <i>errno</i> shall be set to indicate the error.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_387_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>mq_send</i>() <sup>[<a href="javascript:open_code('TMO')">TMO</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> and <i>mq_timedsend</i>() <img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
functions shall fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EAGAIN]</dt>
|
|
|
|
<dd>The O_NONBLOCK flag is set in the message queue description associated with <i>mqdes</i>, and the specified message queue is
|
|
full.</dd>
|
|
|
|
<dt>[EBADF]</dt>
|
|
|
|
<dd>The <i>mqdes</i> argument is not a valid message queue descriptor open for writing.</dd>
|
|
|
|
<dt>[EINTR]</dt>
|
|
|
|
<dd>A signal interrupted the call to <i>mq_send</i>() <sup>[<a href="javascript:open_code('TMO')">TMO</a>]</sup> <img src=
|
|
"../images/opt-start.gif" alt="[Option Start]" border="0"> or <i>mq_timedsend</i>(). <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></dd>
|
|
|
|
<dt>[EINVAL]</dt>
|
|
|
|
<dd>The value of <i>msg_prio</i> was outside the valid range.</dd>
|
|
|
|
<dt>[EINVAL]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('TMO')">TMO</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The process or thread would have blocked, and the <i>abs_timeout</i> parameter specified a nanoseconds field value less than zero
|
|
or greater than or equal to 1000 million. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
|
|
<dt>[EMSGSIZE]</dt>
|
|
|
|
<dd>The specified message length, <i>msg_len</i>, exceeds the message size attribute of the message queue.</dd>
|
|
|
|
<dt>[ETIMEDOUT]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('TMO')">TMO</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The O_NONBLOCK flag was not set when the message queue was opened, but the timeout expired before the message could be added to the
|
|
queue. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_387_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_387_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>The value of the symbol {MQ_PRIO_MAX} limits the number of priority levels supported by the application. Message priorities
|
|
range from 0 to {MQ_PRIO_MAX}-1.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_387_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_387_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_387_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="mq_open.html"><i>mq_open</i>()</a> , <a href="mq_receive.html"><i>mq_receive</i>()</a> , <a href=
|
|
"mq_setattr.html"><i>mq_setattr</i>()</a> , <a href="mq_timedreceive.html"><i>mq_timedreceive</i>()</a> , <a href=
|
|
"time.html"><i>time</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/mqueue.h.html"><i><mqueue.h></i></a>, <a href="../basedefs/time.h.html"><i><time.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_387_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 5. Included for alignment with the POSIX Realtime Extension.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_387_12"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>mq_send</i>() function is marked as part of the Message Passing option.</p>
|
|
|
|
<p>The [ENOSYS] error condition has been removed as stubs need not be provided if an implementation does not support the Message
|
|
Passing option.</p>
|
|
|
|
<p>The <i>mq_timedsend</i>() function is added for alignment with IEEE Std 1003.1d-1999.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|