1MQ_SEND(3)                 Linux Programmer's Manual                MQ_SEND(3)
2
3
4

NAME

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

SYNOPSIS

9       #include <mqueue.h>
10
11       mqd_t mq_send(mqd_t mqdes, const char *msg_ptr,
12                     size_t msg_len, unsigned msg_prio);
13
14       #define _XOPEN_SOURCE 600
15       #include <time.h>
16       #include <mqueue.h>
17
18       mqd_t mq_timedsend(mqd_t mqdes, const char *msg_ptr,
19                     size_t msg_len, unsigned msg_prio,
20                     const struct timespec *abs_timeout);
21
22       Link with -lrt.
23

DESCRIPTION

25       mq_send()  adds  the message pointed to by msg_ptr to the message queue
26       referred to by the descriptor mqdes.  The  msg_len  argument  specifies
27       the  length  of  the message pointed to by msg_ptr; this length must be
28       less than or equal to the queue's  mq_msgsize  attribute.   Zero-length
29       messages are allowed.
30
31       The msg_prio argument is a non-negative integer that specifies the pri‐
32       ority of this message.  Messages are placed on the queue in  decreasing
33       order  of  priority,  with  newer  messages  of the same priority being
34       placed after older messages with the same priority.
35
36       If the message queue is already full (i.e., the number of  messages  on
37       the  queue  equals  the queue's mq_maxmsg attribute), then, by default,
38       mq_send() blocks until sufficient space becomes available to allow  the
39       message to be queued, or until the call is interrupted by a signal han‐
40       dler.  If the O_NONBLOCK flag is enabled for the message queue descrip‐
41       tion, then the call instead fails immediately with the error EAGAIN.
42
43       mq_timedsend() behaves just like mq_send(), except that if the queue is
44       full and the O_NONBLOCK flag is  not  enabled  for  the  message  queue
45       description,  then  abs_timeout points to a structure which specifies a
46       ceiling on the time for which the call will block.  This ceiling is  an
47       absolute  timeout  in seconds and nanoseconds since the Epoch (midnight
48       on the morning of 1 January 1970), specified in  the  following  struc‐
49       ture:
50
51           struct timespec {
52               time_t tv_sec;        /* seconds */
53               long   tv_nsec;       /* nanoseconds */
54           };
55
56       If  the  message  queue is full, and the timeout has already expired by
57       the time of the call, mq_timedsend() returns immediately.
58

RETURN VALUE

60       On success, mq_send() and mq_timedsend() return zero; on error,  -1  is
61       returned, with errno set to indicate the error.
62

ERRORS

64       EAGAIN The  queue  was  empty,  and the O_NONBLOCK flag was set for the
65              message queue description referred to by mqdes.
66
67       EBADF  The descriptor specified in mqdes was invalid.
68
69       EINTR  The call was interrupted by a signal handler; see signal(7).
70
71       EINVAL The call would have blocked, and abs_timeout was invalid, either
72              because  tv_sec  was less than zero, or because tv_nsec was less
73              than zero or greater than 1000 million.
74
75       EMSGSIZE
76              msg_len was greater than the mq_msgsize attribute of the message
77              queue.
78
79       ETIMEDOUT
80              The call timed out before a message could be transferred.
81

CONFORMING TO

83       POSIX.1-2001.
84

NOTES

86       On  Linux,  mq_timedsend() is a system call, and mq_send() is a library
87       function layered on top of that system call.
88

SEE ALSO

90       mq_close(3), mq_getattr(3),  mq_notify(3),  mq_open(3),  mq_receive(3),
91       mq_unlink(3), feature_test_macros(7), mq_overview(7), time(7)
92

COLOPHON

94       This  page  is  part of release 3.22 of the Linux man-pages project.  A
95       description of the project, and information about reporting  bugs,  can
96       be found at http://www.kernel.org/doc/man-pages/.
97
98
99
100Linux                             2008-09-29                        MQ_SEND(3)
Impressum