#include <nanomsg/nn.h> int nn_recv(int sock, void *data, size_t size, int flags)
nn_recv() function receives a message from the socket sock.
The message body must fit within size bytes, and will be stored
at the location specified by data, unless size is the
NN_MSG, indicating a zero-copy operation.
|This function is provided for API compatibility with legacy libnanomsg. Consider using the relevant modern API instead.|
If size has the special value
NN_MSG, then a zero-copy operation
In this case, instead of copying the message data into the address
specified by data, a new message large enough to hold the message data
will be allocated (as if by the
nn_allocmsg()), and the message
payload will be stored accordingly.
In this case, the value stored at data will not be message data,
but a pointer to the message itself.
In this case, on success, the caller shall take responsibility for
the final disposition of the message (such as by sending it to
another peer using
The flags field may contain the special flag
In this case, if the no message is available for immediate receipt,
the operation shall not block, but instead will fail with the error
This function returns the number of bytes sent on success, and -1 on error.
The operation would block.
The socket sock is not open.
The socket cannot receive in this state.
This protocol cannot receive.
Operation timed out.