flux_send(3)
SYNOPSIS
#include <flux/core.h>
int flux_send (flux_t *h, const flux_msg_t *msg, int flags);
int flux_send_new (flux_t *h, flux_msg_t **msg, int flags);
Link with -lflux-core.
DESCRIPTION
flux_send()
sends msg
using the Flux Message broker,
previously opened with flux_open(3) on handle h
.
flags
is the logical "or" of zero or more of the following flags:
- FLUX_O_TRACE
Dumps
msg
to stderr.- FLUX_O_NONBLOCK
If unable to send, return an error rather than block.
Internally, flags are the logical "or" of flags
and the flags provided
to flux_open(3) when the handle was created.
The message type, topic string, and nodeid affect how the message will be routed by the broker. These attributes are pre-set in the message.
flux_send_new()
is the same, except message ownership is transferred
to the handle h
. The double pointer msg
points to a NULL value if
the message is successfully transferred. The send fails if the message
reference count is greater than one.
RETURN VALUE
flux_send()
returns zero on success. On error, -1 is returned, and
errno
is set appropriately.
ERRORS
- ENOSYS
Handle has no send operation.
- EINVAL
Some arguments were invalid.
- EAGAIN
FLUX_O_NONBLOCK
was selected andflux_send()
would block.
EXAMPLES
This example opens the Flux broker and publishes an event message.
#include <flux/core.h>
#include "die.h"
int main (int argc, char **argv)
{
flux_t *h;
flux_msg_t *msg;
if (!(h = flux_open (NULL, 0)))
die ("flux open %s", "NULL");
if (!(msg = flux_event_encode ("snack.bar.closing", NULL)))
die ("flux_event_encode");
if (flux_send (h, msg, 0) < 0)
die ("flux_send");
flux_msg_destroy (msg);
flux_close (h);
return (0);
}
RESOURCES
Flux: http://flux-framework.org
Flux RFC: https://flux-framework.readthedocs.io/projects/flux-rfc
Issue Tracker: https://github.com/flux-framework/flux-core/issues