'\" t
.\"     Title: nn_send
.\"    Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.26
.\"      Date: 2021-02-08
.\"    Manual: NNG Reference Manual
.\"    Source: \ \&
.\"  Language: English
.\"
.TH "NN_SEND" "3compat" "2021-02-08" "\ \&" "NNG Reference Manual"
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.ss \n[.ss] 0
.nh
.ad l
.de URL
\fI\\$2\fP <\\$1>\\$3
..
.als MTO URL
.if \n[.g] \{\
.  mso www.tmac
.  am URL
.    ad l
.  .
.  am MTO
.    ad l
.  .
.  LINKSTYLE blue R < >
.\}
.SH "NAME"
nn_send \- send data (compatible API)
.SH "SYNOPSIS"
.sp
.if n .RS 4
.nf
.fam C
#include <nanomsg/nn.h>

int nn_send(int sock, const void *data, size_t size, int flags)
.fam
.fi
.if n .RE
.SH "DESCRIPTION"
.sp
The \f(CRnn_send()\fP function creates a message containing \fIdata\fP (of size \fIsize\fP),
and sends using the socket \fIsock\fP.
.if n .sp
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
.B Note
.ps -1
.br
.sp
This function is provided for API
compatibility with legacy \fIlibnanomsg\fP.
Consider using the relevant modern API instead.
.sp .5v
.RE
.sp
If \fIsize\fP has the special value \f(CRNN_MSG\fP, then a zero\-copy operation
is performed.
In this case, \fIdata\fP points not to the message content itself, but instead
is a pointer to the pointer, an extra level of pointer indirection.
The message must have been previously allocated by
\f(CRnn_allocmsg()\fP or
\f(CRnn_recvmsg()\fP\f(CR, using the same `NN_MSG\fP size.
In this case, the ownership of the message shall remain with
the caller, unless the function returns 0, indicating that the
function has taken responsibility for delivering or disposing of the
message.
.sp
The \fIflags\fP field may contain the special flag \f(CRNN_DONTWAIT\fP.
In this case, if the socket is unable to accept more data for sending,
the operation shall not block, but instead will fail with the error \f(CREAGAIN\fP.
.if n .sp
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
.B Note
.ps -1
.br
.sp
The send operation is performed asynchronously, and may not have
completed before this function returns control to the caller.
.sp .5v
.RE
.SH "RETURN VALUES"
.sp
This function returns the number of bytes sent on success, and \-1 on error.
.SH "ERRORS"
.sp
\f(CREAGAIN\fP
.RS 4
The operation would block.
.RE
.sp
\f(CREBADF\fP
.RS 4
The socket \fIsock\fP is not open.
.RE
.sp
\f(CREFSM\fP
.RS 4
The socket cannot send in this state.
.RE
.sp
\f(CRENOTSUP\fP
.RS 4
This protocol cannot send.
.RE
.sp
\f(CRETIMEDOUT\fP
.RS 4
Operation timed out.
.RE
.SH "SEE ALSO"
.sp
nn_errno(3compat),
nn_recv(3compat),
nn_sendmsg(3compat),
nn_socket(3compat),
nn_compat(3compat),
nng(7)