Imported Upstream version 1.46.0
[platform/upstream/nghttp2.git] / doc / nghttp2_session_mem_send.rst
1
2 nghttp2_session_mem_send
3 ========================
4
5 Synopsis
6 --------
7
8 *#include <nghttp2/nghttp2.h>*
9
10 .. function:: ssize_t nghttp2_session_mem_send(nghttp2_session *session, const uint8_t **data_ptr)
11
12     
13     Returns the serialized data to send.
14     
15     This function behaves like `nghttp2_session_send()` except that it
16     does not use :type:`nghttp2_send_callback` to transmit data.
17     Instead, it assigns the pointer to the serialized data to the
18     *\*data_ptr* and returns its length.  The other callbacks are called
19     in the same way as they are in `nghttp2_session_send()`.
20     
21     If no data is available to send, this function returns 0.
22     
23     This function may not return all serialized data in one invocation.
24     To get all data, call this function repeatedly until it returns 0
25     or one of negative error codes.
26     
27     The assigned *\*data_ptr* is valid until the next call of
28     `nghttp2_session_mem_send()` or `nghttp2_session_send()`.
29     
30     The caller must send all data before sending the next chunk of
31     data.
32     
33     This function returns the length of the data pointed by the
34     *\*data_ptr* if it succeeds, or one of the following negative error
35     codes:
36     
37     :macro:`nghttp2_error.NGHTTP2_ERR_NOMEM`
38         Out of memory.
39     
40     .. note::
41     
42       This function may produce very small byte string.  If that is the
43       case, and application disables Nagle algorithm (``TCP_NODELAY``),
44       then writing this small chunk leads to very small packet, and it
45       is very inefficient.  An application should be responsible to
46       buffer up small chunks of data as necessary to avoid this
47       situation.