pub type nghttp2_send_callback = Option<unsafe extern "C" fn(session: *mut nghttp2_session, data: *const u8, length: usize, flags: c_int, user_data: *mut c_void) -> isize>;
Expand description

@functypedef

Callback function invoked when |session| wants to send data to the remote peer. The implementation of this function must send at most |length| bytes of data stored in |data|. The |flags| is currently not used and always 0. It must return the number of bytes sent if it succeeds. If it cannot send any single byte without blocking, it must return :enum:NGHTTP2_ERR_WOULDBLOCK. For other errors, it must return :enum:NGHTTP2_ERR_CALLBACK_FAILURE. The |user_data| pointer is the third argument passed in to the call to nghttp2_session_client_new() or nghttp2_session_server_new().

This callback is required if the application uses nghttp2_session_send() to send data to the remote endpoint. If the application uses solely nghttp2_session_mem_send() instead, this callback function is unnecessary.

To set this callback to :type:nghttp2_session_callbacks, use nghttp2_session_callbacks_set_send_callback().

.. note::

The |length| may be very small. If that is the case, and application disables Nagle algorithm (TCP_NODELAY), then just writing |data| to the network stack leads to very small packet, and it is very inefficient. An application should be responsible to buffer up small chunks of data as necessary to avoid this situation.