<p>We use libevent in this tutorial to handle networking I/O. Please
note that nghttp2 iteself does not depends on libevent.</p>
note that nghttp2 itself does not depend on libevent.</p>
<p>First we do some setup routine for libevent and OpenSSL library in
function <ttclass="docutils literal"><spanclass="pre">main()</span></tt> and <ttclass="docutils literal"><spanclass="pre">run()</span></tt>, which is not so relevant to nghttp2
library use. The one thing you should look at is setup NPN callback.
...
...
@@ -248,8 +248,8 @@ the remote server:</p>
<p>We set 3 callbacks for the bufferevent: <ttclass="docutils literal"><spanclass="pre">reacb</span></tt>, <ttclass="docutils literal"><spanclass="pre">writecb</span></tt> and
@@ -406,8 +406,8 @@ frames. The <tt class="docutils literal"><span class="pre">session_send()</span>
</pre></div>
</div>
<p>The <aclass="reference internal"href="apiref.html#nghttp2_session_send"title="nghttp2_session_send"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_send()</span></tt></a> function serializes the frame into wire
format and call <ttclass="xref c c-member docutils literal"><spanclass="pre">nghttp2_callbacks.nghttp2_send_callback</span></tt> with
it. We set <ttclass="docutils literal"><spanclass="pre">send_callback()</span></tt> function as
format and call <aclass="reference internal"href="apiref.html#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> with
it. We set <ttclass="docutils literal"><spanclass="pre">send_callback()</span></tt> function to
<aclass="reference internal"href="apiref.html#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> in
<ttclass="docutils literal"><spanclass="pre">initialize_nghttp2_session()</span></tt> function described earlier. It is
defined as follows:</p>
...
...
@@ -456,7 +456,7 @@ conditions as well. Using these information, nghttp2 session object
will tell whether the connection should be dropped or not. More
specifically, both <aclass="reference internal"href="apiref.html#nghttp2_session_want_read"title="nghttp2_session_want_read"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_want_read()</span></tt></a> and
<aclass="reference internal"href="apiref.html#nghttp2_session_want_write"title="nghttp2_session_want_write"><ttclass="xref c c-func docutils literal"><spanclass="pre">nghttp2_session_want_write()</span></tt></a> return 0, we have no business in the
connection. But since we have using bufferevent and its deferred
connection. But since we are using bufferevent and its deferred
callback option, the bufferevent output buffer may contain the pending
data when the <ttclass="docutils literal"><spanclass="pre">writecb()</span></tt> is called. To handle this situation, we
also check whether the output buffer is empty or not. If these