nanomsg
Home Download Documentation Development Community Support
NOTE: This documentation is for version 0.1-alpha of nanomsg, but the latest released version is 1.1.5. Please see the documentation for 1.1.5 for the most up-to-date information.
nn_send(3)

SYNOPSIS

#include <nanomsg/nn.h>

int nn_send (int s, const void *buf, size_t len, int flags);

DESCRIPTION

The function will send a message containing the data from buffer pointed to by buf parameter to the socket s. The message will be len bytes long.

Alternatively, to send a buffer allocated by nn_allocmsg(3) function set the buf parameter to point to the pointer to the buffer and len parameter to NN_MSG constant. In this case the buffer will be deallocated by nn_send function. Trying to deallocate it afterwards will result in undefined behaviour.

Which of the peers the message will be sent to is determined by the particular socket type.

The flags argument is a combination of the flags defined below:

NN_DONTWAIT

Specifies that the operation should be performed in non-blocking mode. If the message cannot be sent straight away, the function will fail with errno set to EAGAIN.

RETURN VALUE

If the function succeeds, the number of bytes in the message is returned. Otherwise, a negative number is returned and errno is set to to one of the values defined below.

ERRORS

EBADF

The provided socket is invalid.

ENOTSUP

The operation is not supported by this socket type.

EFSM

The operation cannot be performed on this socket at the moment because the socket is not in the appropriate state. This error may occur with socket types that switch between several states.

EAGAIN

Non-blocking mode was requested and the message cannot be sent at the moment.

EINTR

The operation was interrupted by delivery of a signal before the message was sent.

ETIMEDOUT

Individual socket types may define their own specific timeouts. If such timeout is hit, this error will be returned.

ETERM

The library is terminating.

EXAMPLE

nbytes = nn_send (s, "ABC", 3, 0);
assert (nbytes == 3);

SEE ALSO

AUTHORS

Martin Sustrik <sustrik@250bpm.com>


"nanomsg" is a trademark of Garrett D'Amore.