1NN_ALLOCMSG(3)                   nanomsg 1.1.5                  NN_ALLOCMSG(3)
2
3
4

NAME

6       nn_allocmsg - allocate a message
7

SYNOPSIS

9       #include <nanomsg/nn.h>
10
11       void *nn_allocmsg (size_t size, int type);
12

DESCRIPTION

14       Allocate a message of the specified size to be sent in zero-copy
15       fashion. The content of the message is undefined after allocation and
16       it should be filled in by the user. While nn_send(3) and nn_sendmsg(3)
17       allow to send arbitrary buffers, buffers allocated using nn_allocmsg()
18       can be more efficient for large messages as they allow for using
19       zero-copy techniques.
20
21       type parameter specifies type of allocation mechanism to use. Zero is
22       the default one, however, individual transport mechanisms may define
23       their own allocation mechanisms, such as allocating in shared memory or
24       allocating a memory block pinned down to a physical memory address.
25       Such allocation, when used with the transport that defines them, should
26       be more efficient than the default allocation mechanism.
27

RETURN VALUE

29       If the function succeeds pointer to newly allocated buffer is returned.
30       Otherwise, NULL is returned and errno is set to to one of the values
31       defined below.
32

ERRORS

34       EINVAL
35           Supplied allocation type is invalid.
36
37       ENOMEM
38           Not enough memory to allocate the message.
39

EXAMPLE

41           void *buf = nn_allocmsg (12, 0);
42           memcpy (buf, "Hello world!", 12);
43           nn_send (s, &buf, NN_MSG, 0);
44

SEE ALSO

46       nn_freemsg(3) nn_reallocmsg(3) nn_send(3) nn_sendmsg(3) nanomsg(7)
47

AUTHORS

49       Martin Sustrik <sustrik@250bpm.com>
50
51
52
53                                  2021-01-26                    NN_ALLOCMSG(3)
Impressum