1mq_send(3C)              Standard C Library Functions              mq_send(3C)
2
3
4

NAME

6       mq_send, mq_timedsend, mq_reltimedsend_np - send a message to a message
7       queue
8

SYNOPSIS

10       #include <mqueue.h>
11
12       int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
13            unsigned msg_prio);
14
15
16       #include <mqueue.h>
17       #include <time.h>
18
19       int mq_timedsend(mqd_t mqdes, const char *msg_ptr,
20            size_t msg_len, unsigned msg_prio,
21            const struct timespec *restrict abs_timeout);
22
23
24       int mq_reltimedsend_np(mqd_t mqdes, const char *msg_ptr,
25            size_t msg_len, unsigned msg_prio,
26            const struct timespec *restrict rel_timeout);
27
28

DESCRIPTION

30       The mq_send() function adds the message  pointed  to  by  the  argument
31       msg_ptr  to  the message queue specified by mqdes. The msg_len argument
32       specifies the length of the message in bytes pointed to by msg_ptr. The
33       value  of  msg_len is less than or equal to the mq_msgsize attribute of
34       the message queue, or mq_send() fails.
35
36
37       If the specified message queue is not full, mq_send() behaves as if the
38       message is inserted into the message queue at the position indicated by
39       the msg_prio argument.  A  message  with  a  larger  numeric  value  of
40       msg_prio  is  inserted before messages with lower values of msg_prio. A
41       message will be inserted after other messages in  the  queue,  if  any,
42       with  equal  msg_prio.  The value of msg_prio must be greater than zero
43       and less than or equal to  MQ_PRIO_MAX.
44
45
46       If the specified message queue is full and O_NONBLOCK is not set in the
47       message  queue  description  associated with mqdes (see mq_open(3C) and
48       mq_setattr(3C)), mq_send() blocks  until  space  becomes  available  to
49       enqueue  the message, or until mq_send() is interrupted by a signal. If
50       more than one thread is waiting to send when space becomes available in
51       the  message  queue,  then the thread of the highest priority which has
52       been waiting the longest is unblocked to send its  message.  Otherwise,
53       it  is  unspecified which waiting thread is unblocked. If the specified
54       message queue is full and  O_NONBLOCK  is  set  in  the  message  queue
55       description  associated  with  mqdes,  the  message  is  not queued and
56       mq_send() returns an error.
57
58
59       The mq_timedsend() function adds a message to the message queue  speci‐
60       fied  by  mqdes  in the manner defined for the mq_send() function. How‐
61       ever, if the specified message queue is full and O_NONBLOCK is not  set
62       in  the  message  queue description associated with mqdes, the wait for
63       sufficient room in the queue is terminated when the  specified  timeout
64       expires.  If  O_NONBLOCK  is set in the message queue description, this
65       function is equivalent to mq_send().
66
67
68       The mq_reltimedsend_np() function is identical  to  the  mq_timedsend()
69       function,  except  that  the  timeout  is  specified as a relative time
70       interval.
71
72
73       For mq_timedsend(), the timeout expires when the absolute  time  speci‐
74       fied  by  abs_timeout  passes,  as measured by the CLOCK_REALTIME clock
75       (that is, when the value of that clock equals or exceeds  abs_timeout),
76       or  if  the  absolute  time  specified  by abs_timeout has already been
77       passed at the time of the call.
78
79
80       For mq_reltimedsend_np(), the timeout expires when  the  time  interval
81       specified  by  rel_timeout  passes,  as  measured by the CLOCK_REALTIME
82       clock, or if the time interval specified by rel_timeout is negative  at
83       the time of the call.
84
85
86       The  resolution  of the timeout is the resolution of the CLOCK_REALTIME
87       clock. The timespec argument is defined in the <time.h> header.
88
89
90       Under no circumstance does the operation fail with a timeout  if  there
91       is  sufficient  room  in  the queue to add the message immediately. The
92       validity of the timeout parameter need not be  checked  when  there  is
93       sufficient room in the queue.
94

RETURN VALUES

96       Upon successful completion, mq_send(), mq_timedsend(), and mq_reltimed‐
97       send_np() return 0. Otherwise, no message is  enqueued,  the  functions
98       return −1, and errno is set to indicate the error.
99

ERRORS

101       The  mq_send(), mq_timedsend(), and mq_reltimedsend_np() functions will
102       fail if:
103
104       EAGAIN       The  O_NONBLOCK flag is set in the message queue  descrip‐
105                    tion  associated  with  mqdes,  and  the specified message
106                    queue is full.
107
108
109       EBADF        The mqdes argument is not a valid message queue descriptor
110                    open for writing.
111
112
113       EINTR        A signal interrupted the function call.
114
115
116       EINVAL       The value of msg_prio was outside the valid range.
117
118
119       EINVAL       The  process or thread would have blocked, and the timeout
120                    parameter specified a nanoseconds field  value  less  than
121                    zero or greater than or equal to 1,000 million.
122
123
124       EMSGSIZE     The specified message length, msg_len, exceeds the message
125                    size attribute of the message queue.
126
127
128       ETIMEDOUT    The O_NONBLOCK flag was not set when the message queue was
129                    opened,  but  the timeout expired before the message could
130                    be added to the queue.
131
132

ATTRIBUTES

134       See attributes(5) for descriptions of the following attributes:
135
136
137
138
139       ┌─────────────────────────────┬─────────────────────────────┐
140       │ATTRIBUTE TYPE               │ATTRIBUTE VALUE              │
141       ├─────────────────────────────┼─────────────────────────────┤
142       │Interface Stability          │Committed                    │
143       ├─────────────────────────────┼─────────────────────────────┤
144       │MT-Level                     │MT-Safe                      │
145       ├─────────────────────────────┼─────────────────────────────┤
146       │Standard                     │See below.                   │
147       └─────────────────────────────┴─────────────────────────────┘
148
149
150       For mq_send() and mq_timedsend(), see standards(5).
151

SEE ALSO

153       sysconf(3C),     mqueue.h(3HEAD),     mq_open(3C),      mq_receive(3C),
154       mq_setattr(3C), attributes(5), standards(5)
155
156
157
158SunOS 5.11                        5 Feb 2008                       mq_send(3C)
Impressum