<h2>Remarks<aclass="headerlink"href="#remarks"title="Permalink to this headline">¶</a></h2>
<p>Do not call <aclass="reference internal"href="#nghttp2_session_send"title="nghttp2_session_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_send()</span></tt></a>, <aclass="reference internal"href="#nghttp2_session_recv"title="nghttp2_session_recv"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_recv()</span></tt></a> or
<aclass="reference internal"href="#nghttp2_session_mem_recv"title="nghttp2_session_mem_recv"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_mem_recv()</span></tt></a> from the nghttp2 callback functions
directly or indirectly. It will lead to the crash. You can submit
requests or frames in the callbacks then call <aclass="reference internal"href="#nghttp2_session_send"title="nghttp2_session_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_send()</span></tt></a>,
<aclass="reference internal"href="#nghttp2_session_recv"title="nghttp2_session_recv"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_recv()</span></tt></a> or <aclass="reference internal"href="#nghttp2_session_mem_recv"title="nghttp2_session_mem_recv"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_mem_recv()</span></tt></a> outside of the
callbacks.</p>
<p>Do not call <aclass="reference internal"href="#nghttp2_session_send"title="nghttp2_session_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_send()</span></tt></a>, <aclass="reference internal"href="#nghttp2_session_mem_send"title="nghttp2_session_mem_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_mem_send()</span></tt></a>,
<aclass="reference internal"href="#nghttp2_session_recv"title="nghttp2_session_recv"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_recv()</span></tt></a> or <aclass="reference internal"href="#nghttp2_session_mem_recv"title="nghttp2_session_mem_recv"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_mem_recv()</span></tt></a> from the nghttp2
callback functions directly or indirectly. It will lead to the
crash. You can submit requests or frames in the callbacks then call
these functions outside the callbacks.</p>
</div>
<divclass="section"id="macros">
<h2>Macros<aclass="headerlink"href="#macros"title="Permalink to this headline">¶</a></h2>
...
...
@@ -1355,6 +1354,10 @@ it must return <a class="reference internal" href="#NGHTTP2_ERR_WOULDBLOCK" titl
must return <aclass="reference internal"href="#NGHTTP2_ERR_CALLBACK_FAILURE"title="NGHTTP2_ERR_CALLBACK_FAILURE"><ttclass="xref c c-macro docutils literal"><spanclass="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>. The <em>user_data</em>
pointer is the third argument passed in to the call to
<aclass="reference internal"href="#nghttp2_session_client_new"title="nghttp2_session_client_new"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_client_new()</span></tt></a> or <aclass="reference internal"href="#nghttp2_session_server_new"title="nghttp2_session_server_new"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_server_new()</span></tt></a>.</p>
<p>This callback is required if the application uses
<aclass="reference internal"href="#nghttp2_session_send"title="nghttp2_session_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_send()</span></tt></a> to send data to the remote endpoint. If
the application uses <aclass="reference internal"href="#nghttp2_session_mem_send"title="nghttp2_session_mem_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_mem_send()</span></tt></a> instead, this
callback function is unnecessary.</p>
</dd></dl>
<dlclass="type">
...
...
@@ -1372,6 +1375,10 @@ it gets EOF before it reads any single byte, it must return
<aclass="reference internal"href="#NGHTTP2_ERR_WOULDBLOCK"title="NGHTTP2_ERR_WOULDBLOCK"><ttclass="xref c c-macro docutils literal"><spanclass="pre">NGHTTP2_ERR_WOULDBLOCK</span></tt></a>. The <em>user_data</em> pointer is the
third argument passed in to the call to
<aclass="reference internal"href="#nghttp2_session_client_new"title="nghttp2_session_client_new"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_client_new()</span></tt></a> or <aclass="reference internal"href="#nghttp2_session_server_new"title="nghttp2_session_server_new"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_server_new()</span></tt></a>.</p>
<p>This callback is required if the application uses
<aclass="reference internal"href="#nghttp2_session_recv"title="nghttp2_session_recv"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_recv()</span></tt></a> to receive data from the remote
endpoint. If the application uses <aclass="reference internal"href="#nghttp2_session_mem_recv"title="nghttp2_session_mem_recv"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_mem_recv()</span></tt></a>
instead, this callback function is unnecessary.</p>
</dd></dl>
<dlclass="type">
...
...
@@ -1614,14 +1621,18 @@ inclusive. Choosing number not in this range will be treated as
<dtid="nghttp2_session_callbacks.send_callback">
<aclass="reference internal"href="#nghttp2_send_callback"title="nghttp2_send_callback">nghttp2_send_callback</a><ttclass="descname">send_callback</tt><aclass="headerlink"href="#nghttp2_session_callbacks.send_callback"title="Permalink to this definition">¶</a></dt>
<dd><p>Callback function invoked when the <em>session</em> wants to send data
to the remote peer.</p>
to the remote peer. This callback is not necessary if the
application uses <aclass="reference internal"href="#nghttp2_session_mem_send"title="nghttp2_session_mem_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_mem_send()</span></tt></a> to serialize data
to transmit.</p>
</dd></dl>
<dlclass="member">
<dtid="nghttp2_session_callbacks.recv_callback">
<aclass="reference internal"href="#nghttp2_recv_callback"title="nghttp2_recv_callback">nghttp2_recv_callback</a><ttclass="descname">recv_callback</tt><aclass="headerlink"href="#nghttp2_session_callbacks.recv_callback"title="Permalink to this definition">¶</a></dt>
<dd><p>Callback function invoked when the <em>session</em> wants to receive
data from the remote peer.</p>
data from the remote peer. This callback is not necessary if the
application uses <aclass="reference internal"href="#nghttp2_session_mem_recv"title="nghttp2_session_mem_recv"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_mem_recv()</span></tt></a> to process received
data.</p>
</dd></dl>
<dlclass="member">
...
...
@@ -1864,6 +1875,32 @@ negative error codes:</p>
</dl>
</dd></dl>
<dlclass="function">
<dtid="nghttp2_session_mem_send">
ssize_t <ttclass="descname">nghttp2_session_mem_send</tt><big>(</big><aclass="reference internal"href="#nghttp2_session"title="nghttp2_session">nghttp2_session</a><em> *session</em>, const uint8_t<em> **data_ptr</em><big>)</big><aclass="headerlink"href="#nghttp2_session_mem_send"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the serialized data to send.</p>
<p>This function behaves like <aclass="reference internal"href="#nghttp2_session_mem_send"title="nghttp2_session_mem_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_mem_send()</span></tt></a> except that
it does not use <aclass="reference internal"href="#nghttp2_session_callbacks.send_callback"title="nghttp2_session_callbacks.send_callback"><ttclass="xref c c-member docutils literal"><spanclass="pre">nghttp2_session_callbacks.send_callback</span></tt></a>
to transmit data. Instead, it assigns the pointer to the serialized
data to the <em>*data_ptr</em> and returns its length. The other callbacks
are called in the same way as they are in <aclass="reference internal"href="#nghttp2_session_send"title="nghttp2_session_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_send()</span></tt></a>.</p>
<p>If no data is available to send, this function returns 0.</p>
<p>This function may not return all serialized data in one
invocation. To get all data, call this function repeatedly until it
returns 0 or one of negative error codes.</p>
<p>The assigned <em>*data_ptr</em> is valid until the next call of
<aclass="reference internal"href="#nghttp2_session_mem_send"title="nghttp2_session_mem_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_mem_send()</span></tt></a> or <aclass="reference internal"href="#nghttp2_session_send"title="nghttp2_session_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_send()</span></tt></a>.</p>
<p>The caller must send all data before sending the next chunk of
data.</p>
<p>This function returns the length of the data pointed by the
<em>*data_ptr</em> if it succeeds, or one of the following negative error
codes:</p>
<dlclass="docutils">
<dt><aclass="reference internal"href="#NGHTTP2_ERR_NOMEM"title="NGHTTP2_ERR_NOMEM"><ttclass="xref c c-macro docutils literal"><spanclass="pre">NGHTTP2_ERR_NOMEM</span></tt></a></dt>
<dd>Out of memory.</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="nghttp2_session_recv">
int <ttclass="descname">nghttp2_session_recv</tt><big>(</big><aclass="reference internal"href="#nghttp2_session"title="nghttp2_session">nghttp2_session</a><em> *session</em><big>)</big><aclass="headerlink"href="#nghttp2_session_recv"title="Permalink to this definition">¶</a></dt>