IncludeOS icon indicating copy to clipboard operation
IncludeOS copied to clipboard

TCP Connection on_read buffer size no longer in use

Open AndreasAakesson opened this issue 5 years ago • 0 comments

net/tcp/connecion.hpp

  /** Called with a shared buffer and the length of the data when received. */
  using ReadCallback            = delegate<void(buffer_t)>;
  /**
   * @brief      Event when incoming data is received by the connection.
   *             The recv_bufsz determines the size of the receive buffer.
   *             The callback is called when either 1) PSH is seen, or 2) the buffer is full
   *
   * @param[in]  recv_bufsz  The size of the receive buffer
   * @param[in]  callback    The callback
   *
   * @return     This connection
   */
  inline Connection&            on_read(size_t recv_bufsz, ReadCallback callback);

Since #1870 buffer size is now set on the TCP object per stack. Every Connection from that stack will now use these values. The idea was to give better control, since the buffer size passed to on_read would often be hidden when using streams (TCP -> TLS -> WS).

The API is still the same, which means size_t recv_bufsz is today totally ignored. Question is if the API should change (a lot of refactoring), or if we still have a need for this number. There is currently no way to signal to the Connection that I wanna read N bytes every time, without limiting the maximum internal buffer size (which could be a bit wasteful performance wise). What you get now is a shared_ptr to the internal buffer, and it's up to you to process it as you like.

AndreasAakesson avatar Oct 11 '18 09:10 AndreasAakesson