## NAME

mq_timedsend - send a message to a message queue with timeout

## SYNOPSIS

#include <mqueue.h>

int mq_timedsend(mqd_t mqdes , const char *msg_ptr,
  size_t msg_len, unsigned int msg_prio
  const struct timespec *timeout );

## DESCRIPTION

mq_timedsend() adds the message pointed to by msg_ptr to the message queue specified by mqdes.

msg_len specifies the length of the message pointed to by msg_ptr. If msg_len is greater than the mq_msgsize attribute of the message queue, mq_timedsend() returns an error.

If the specified message queue is not full, mq_timedsend() behaves as if the message is inserted into the message queue at the point indicated by msg_prio. A message with larger numeric value of msg_prio is inserted before messages with lower values of msg_prio. A message is inserted after other messages in the queue, if any, with equal msg_prio. The value for msg_prio must be in the range 0 through _POSIX_MQ_PRIO_MAX.

If the specified message queue is full and O_NONBLOCK is not set in the message queue description associated with mqdes, mq_timedsend() blocks until space becomes available to enqueue the message or until the time interval specified in timeout has elapsed. If more than one thread is waiting to send when space becomes available in the message queue, the highest priority thread sends its message. If the specified message queue is full and O_NONBLOCK is set in the message queue description associated with mqdes, the message is not queued, and mq_timedsend() returns an error.

## RETURN VALUES

Upon successful completion, mq_timedsend() returns a value of 0 ; otherwise, no message is enqueued, the function returns -1 , and sets errno to indicate the error condition.

## ERRORS

EAGAIN
  The O_NONBLOCK flag is set in the message queue description associated with mqdes , and the specified message queue is full.
ETIMEDOUT
  The time interval specified by timeout elapsed.
EBADF
  mqdes is not a valid message queue descriptor open for writing.
EINTR
  A signal interrupted the call to mq_timedsend().
EMSGSIZE
  The specified message length, msg_len , exceeds the message size attribute of the message queue.

## SEE ALSO

mq_open(), mq_receive(), mq_setattr(), mq_send()

#### Home page (Kernel)

## < Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2018 >