diff options
author | Garrett D'Amore <garrett@damore.org> | 2016-11-23 15:21:55 -0800 |
---|---|---|
committer | Garrett D'Amore <garrett@damore.org> | 2016-11-23 16:11:42 -0800 |
commit | ac64955a483419241c4e446260df0074deaf2809 (patch) | |
tree | ad857aa14ef76d8da0dee1dc112f24e37af9f7aa /doc/nn_send.adoc | |
parent | b02056f51fc92d45c171e73ef3fd5f8616a648b2 (diff) | |
download | nanomsg-ac64955a483419241c4e446260df0074deaf2809.tar.gz |
fixes #845 Simplify asciidoctor suffixes
Diffstat (limited to 'doc/nn_send.adoc')
-rw-r--r-- | doc/nn_send.adoc | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/doc/nn_send.adoc b/doc/nn_send.adoc new file mode 100644 index 0000000..6aa4a04 --- /dev/null +++ b/doc/nn_send.adoc @@ -0,0 +1,98 @@ +nn_send(3) +========== + +NAME +---- +nn_send - send a message + + +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#,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 a successful call to _nn_send_ will +deallocate the buffer. 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, -1 is returned and 'errno' is set to to one of the +values defined below. + + +ERRORS +------ +*EFAULT*:: +'buf' is NULL or 'len' is NN_MSG and the message pointer (pointed to by +'buf') is NULL. +*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 +------- + +Using data directly: + +---- +nbytes = nn_send (s, "ABC", 3, 0); +assert (nbytes == 3); +---- + +Using a pre-allocated message buffer: + +---- +void *msg = nn_allocmsg(3, 0); +strncpy(msg, "ABC", 3); +nbytes = nn_send (s, &msg, NN_MSG, 0); +assert (nbytes == 3); +---- + + +SEE ALSO +-------- +<<nn_recv#,nn_recv(3)>> +<<nn_sendmsg#,nn_sendmsg(3)>> +<<nn_socket#,nn_socket(3)>> +<<nanomsg#,nanomsg(7)>> + +AUTHORS +------- +link:mailto:sustrik@250bpm.com[Martin Sustrik] + |