MQ_SEND(3)                 POSIX Programmer's Manual                MQ_SEND(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       mq_send, mq_timedsend -- send a message to a message queue (RREEAALLTTIIMMEE)

SSYYNNOOPPSSIISS
       #include <mqueue.h>

       int mq_send(mqd_t _m_q_d_e_s, const char *_m_s_g___p_t_r, size_t _m_s_g___l_e_n,
           unsigned _m_s_g___p_r_i_o);

       #include <mqueue.h>
       #include <time.h>

       int mq_timedsend(mqd_t _m_q_d_e_s, const char *_m_s_g___p_t_r, size_t _m_s_g___l_e_n,
           unsigned _m_s_g___p_r_i_o, const struct timespec *_a_b_s_t_i_m_e);

DDEESSCCRRIIPPTTIIOONN
       The _m_q___s_e_n_d() function shall add the message pointed to by the argument
       _m_s_g___p_t_r to the message queue specified by _m_q_d_e_s.  The _m_s_g___l_e_n argument
       specifies the length of the message, in bytes, pointed to by _m_s_g___p_t_r.
       The value of _m_s_g___l_e_n shall be less than or equal to the _m_q___m_s_g_s_i_z_e
       attribute of the message queue, or _m_q___s_e_n_d() shall fail.

       If the specified message queue is not full, _m_q___s_e_n_d() shall behave as
       if the message is inserted into the message queue at the position
       indicated by the _m_s_g___p_r_i_o argument. A message with a larger numeric
       value of _m_s_g___p_r_i_o shall be inserted before messages with lower values
       of _m_s_g___p_r_i_o.  A message shall be inserted after other messages in the
       queue, if any, with equal _m_s_g___p_r_i_o.  The value of _m_s_g___p_r_i_o shall be
       less than {MQ_PRIO_MAX}.

       If the specified message queue is full and O_NONBLOCK is not set in the
       message queue description associated with _m_q_d_e_s, _m_q___s_e_n_d() shall block
       until space becomes available to enqueue the message, or until
       _m_q___s_e_n_d() 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 _m_q_d_e_s, the message
       shall not be queued and _m_q___s_e_n_d() shall return an error.

       The _m_q___t_i_m_e_d_s_e_n_d() function shall add a message to the message queue
       specified by _m_q_d_e_s in the manner defined for the _m_q___s_e_n_d() function.
       However, if the specified message queue is full and O_NONBLOCK is not
       set in the message queue description associated with _m_q_d_e_s, 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 _m_q___s_e_n_d().

       The timeout shall expire when the absolute time specified by _a_b_s_t_i_m_e
       passes, as measured by the clock on which timeouts are based (that is,
       when the value of that clock equals or exceeds _a_b_s_t_i_m_e), or if the
       absolute time specified by _a_b_s_t_i_m_e has already been passed at the time
       of the call.

       The timeout shall be based on the CLOCK_REALTIME clock.  The resolution
       of the timeout shall be the resolution of the clock on which it is
       based. The _t_i_m_e_s_p_e_c argument is defined in the _<_t_i_m_e_._h_> header.

       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 _a_b_s_t_i_m_e parameter need not be checked when there is
       sufficient room in the queue.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, the _m_q___s_e_n_d() and _m_q___t_i_m_e_d_s_e_n_d() functions
       shall return a value of zero. Otherwise, no message shall be enqueued,
       the functions shall return -1, and _e_r_r_n_o shall be set to indicate the
       error.

EERRRROORRSS
       The _m_q___s_e_n_d() and _m_q___t_i_m_e_d_s_e_n_d() functions shall fail if:

       EEAAGGAAIINN The O_NONBLOCK flag is set in the message queue description
              associated with _m_q_d_e_s, and the specified message queue is full.

       EEBBAADDFF  The _m_q_d_e_s argument is not a valid message queue descriptor open
              for writing.

       EEIINNTTRR  A signal interrupted the call to _m_q___s_e_n_d() or _m_q___t_i_m_e_d_s_e_n_d().

       EEIINNVVAALL The value of _m_s_g___p_r_i_o was outside the valid range.

       EEIINNVVAALL The process or thread would have blocked, and the _a_b_s_t_i_m_e
              parameter specified a nanoseconds field value less than zero or
              greater than or equal to 1000 million.

       EEMMSSGGSSIIZZEE
              The specified message length, _m_s_g___l_e_n, exceeds the message size
              attribute of the message queue.

       EETTIIMMEEDDOOUUTT
              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.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       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.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _m_q___o_p_e_n(), _m_q___r_e_c_e_i_v_e(), _m_q___s_e_t_a_t_t_r(), _t_i_m_e()

       The Base Definitions volume of POSIX.1-2008, <<mmqquueeuuee..hh>>, <<ttiimmee..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                           MQ_SEND(3)
