⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mq_send.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 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-2003 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, 2003 Edition<br>Copyright &copy; 2001-2003 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 &lt;<a href="../basedefs/mqueue.h.html">mqueue.h</a>&gt;<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> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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 &lt;<a href="../basedefs/mqueue.h.html">mqueue.h</a>&gt;<br> #include &lt;<a href="../basedefs/time.h.html">time.h</a>&gt;<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> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned</tt> <i>msg_prio</i><tt>, const struct timespec *</tt><i>abs_timeout</i><tt>); <imgsrc="../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>() shallfail.</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 queueat the position indicated by the <i>msg_prio</i> argument. A message with a larger numeric value of <i>msg_prio</i> shall beinserted before messages with lower values of <i>msg_prio</i>. A message shall be inserted after other messages in the queue, ifany, 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 asignal. If more than one thread is waiting to send when space becomes available in the message queue and the Priority Schedulingoption is supported, then the thread of the highest priority that has been waiting the longest shall be unblocked to send itsmessage. Otherwise, it is unspecified which waiting thread is unblocked. If the specified message queue is full and O_NONBLOCK isset in the message queue description associated with <i>mqdes</i>, the message shall not be queued and <i>mq_send</i>() shallreturn 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 queuedescription associated with <i>mqdes</i>, the wait for sufficient room in the queue shall be terminated when the specified timeoutexpires. 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 whichtimeouts are based (that is, when the value of that clock equals or exceeds <i>abs_timeout</i>), or if the absolute time specifiedby <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 notsupported, 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 inthe <a href="../basedefs/time.h.html"><i>&lt;time.h&gt;</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 messageimmediately. The validity of the <i>abs_timeout</i> parameter need not be checked when there is sufficient room in the queue. <imgsrc="../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"> &nbsp;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 shallreturn -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"> &nbsp;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 isfull.</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"> &nbsp;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 zeroor 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 thequeue. <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 prioritiesrange 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&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/mqueue.h.html"><i>&lt;mqueue.h&gt;</i></a>, <a href="../basedefs/time.h.html"><i>&lt;time.h&gt;</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 MessagePassing option.</p><p>The <i>mq_timedsend</i>() function is added for alignment with IEEE&nbsp;Std&nbsp;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 &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; 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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -