core.sys.posix.mqueue - D Programming Language
Description: D Programming Language
Keywords: D programming language

Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Forums
  - IRC
  - Community Discord
  - Wiki
  - GitHub
  - Issues
  - Get involved
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# core.sys.posix.mqueue

D header file for Posix Message Queues
Defines external functions required to manage Posix Message Queues
mq_open(3) open a message queue mq_close(3) close a message queue mq_unlink(3) remove a message queue mq_send(3) send a message mq_receive(3) receive a message mq_timedsend(3) send a message with a timeout (linux specific) mq_timedreceive(3) receive a message with a timeout (linux specific) mq_getattr(3) get message queue attributes mq_setattr(3) set message queue attributes mq_notify(3) register asynchronous notify
License:
Boost License 1.0.
Authors:
Andreas Bok Andersen, Mathias Lang
Standards:
POSIX.1-2001.
See Also:
Standard

Source core/sys/posix/mqueue.d

alias `mqd_t` = int;
  Message queue descriptor.
struct `mq_attr`;
  Used in getting and setting the attributes of a message queue.
  c_long `mq_flags`;
    Message queue flags.
  c_long `mq_maxmsg`;
    Maximum number of messages.
  c_long `mq_msgsize`;
    Maximum message size.
  c_long `mq_curmsgs`;
    Number of messages currently queued.
nothrow @nogc mqd_t `mq_open`(const(char)* `name`, int `oflag`, ...);
  Establish connection between a process and a message queue `name`.

  Note Linux prototypes are: mqd_t mq_open (const(char)* name, int oflag); mqd_t mq_open (const(char)* name, int oflag, mode_t mode, mq_attr* attr);

  Parameters:

  const(char)* `name` | Name of the message queue to open.
  int `oflag` | determines the type of access used. If O_CREAT is on `oflag`, the third argument is taken as a mode_t, the mode of the created message queue. If O_CREAT is on `oflag`, the fourth argument is taken as a pointer to a `mq_attr' (message queue attributes). If the fourth argument is null, default attributes are used.
  ... | varargs matching the function prototypes

  Returns:
  Message queue descriptor or (mqd_t) -1 on error.
nothrow @nogc int `mq_close`(mqd_t `mqdes`);
  Closes the message queue descriptor mqdes.
  Parameters:

  mqd_t `mqdes` | Message queue descriptor to close.

  Returns:
  On success mq_close() returns 0; on error, -1 is returned, with errno set to indicate the error.
nothrow @nogc int `mq_getattr`(mqd_t `mqdes`, mq_attr* `mqstat`);
  Query status and attributes of message queue `mqdes`.
  Parameters:

  mqd_t `mqdes` | Message queue descriptor.
  mq_attr* `mqstat` | Buffer to fill with the message queue's attributes.

  Returns:
  On success mq_getattr() return 0; on error, -1 is returned, with errno set to indicate the error.
nothrow @nogc int `mq_unlink`(const(char)* `name`);
  Remove the specified message queue `name`.
  Parameters:

  const(char)* `name` | Name of the queue to remove.

  Returns:
  On success mq_unlink() returns 0; on error, -1 is returned, with errno set to indicate the error.
nothrow @nogc int `mq_notify`(mqd_t `mqdes`, const(sigevent)* `notification`);
  Register for notification when a message is available
  Parameters:

  mqd_t `mqdes` | Message queue descriptor.
  const(sigevent)* `notification` | See man 3 `mq_notify` for details.

  Returns:
  On success mq_notify() returns 0; on error, -1 is returned, with errno set to indicate the error.
nothrow @nogc ssize_t `mq_receive`(mqd_t `mqdes`, char* `msg_ptr`, size_t `msg_len`, uint* `msg_prio`);
  Receive the oldest message with the highest priority the message queue
  Parameters:

  mqd_t `mqdes` | Message queue descriptor.
  char* `msg_ptr` | Buffer to write the message to
  size_t `msg_len` | Size of the buffer provided as `msg_ptr`. Must be greater than the mq_msgsize attribute of the queue.
  uint* `msg_prio` | If not null, set to the priority of this message.

  Returns:
  On success, mq_receive() returns the number of bytes in the received message; on error, -1 is returned, with errno set to indicate the error
nothrow @nogc ssize_t `mq_timedreceive`(mqd_t `mqdes`, char* `msg_ptr`, size_t `msg_len`, uint* `msg_prio`, const(timespec)* `abs_timeout`);
  Receive the oldest message with the highest priority the message queue, wait up to a certain timeout.
  Parameters:

  mqd_t `mqdes` | Message queue descriptor.
  char* `msg_ptr` | Buffer to write the message to
  size_t `msg_len` | Size of the buffer provided as `msg_ptr`. Must be greater than the mq_msgsize attribute of the queue.
  uint* `msg_prio` | If not null, set to the priority of this message.
  const(timespec)* `abs_timeout` | Specify a ceiling on the time to block if the queue is empty.

  Returns:
  On success, mq_receive() returns the number of bytes in the received message; on error, -1 is returned, with errno set to indicate the error
nothrow @nogc int `mq_send`(mqd_t `mqdes`, const(char)* `msg_ptr`, size_t `msg_len`, uint `msg_prio`);
  Add a message to a message queue.
  Parameters:

  mqd_t `mqdes` | Message queue descriptor.
  const(char)* `msg_ptr` | Buffer to read the message from
  size_t `msg_len` | Size of the message provided via `msg_ptr`. Must be lower or equal to the mq_msgsize attribute of the queue.
  uint `msg_prio` | Priority of this message.

  Returns:
  On success, mq_send() return zero; on error, -1 is returned, with errno set to indicate the error.
nothrow @nogc int `mq_timedsend`(mqd_t `mqdes`, const(char)* `msg_ptr`, size_t `msg_len`, uint `msg_prio`, const(timespec)* `abs_timeout`);
  Add a message to a message queue, block up to a certain time if the queue is full.
  Parameters:

  mqd_t `mqdes` | Message queue descriptor.
  const(char)* `msg_ptr` | Buffer to read the message from
  size_t `msg_len` | Size of the message provided via `msg_ptr`. Must be lower or equal to the mq_msgsize attribute of the queue.
  uint `msg_prio` | Priority of this message.
  const(timespec)* `abs_timeout` | Specify a ceiling on the time to block if the queue is empty.

  Returns:
  On success, mq_timedsend() return zero; on error, -1 is returned, with errno set to indicate the error.

Copyright © 1999-2023 by the D Language Foundation | Page generated by Ddoc on Sat Jul 15 12:03:28 2023