Skip to content

Add overloads for working with capy/corosio #280

Open

Description

@R-Goc

When trying to write a simple server, I noticed that when writing to a corosio tcp_socket creating the const buffer for the write is rather ugly. Since these libraries are already so tied together methods/overloads for working with capy/corosio would be nice. For example this:

        http::response res;
        res.set_status(http::status::ok);
        auto [ec, n] = co_await m_socket.write_some(
            capy::const_buffer{res.buffer().data(), res.buffer().size()});

Unless I missed some very obvious method, there is no nice way to pass an http::request to write_some. Just .buffer() doesn't work as write_some doesn't accept a string_view.

Activity

  1. vinniefalco commented on Aug 12, 2026

    @vinniefalco
    Member

    Yes there is friction here that needs addressing. How does ASIO do it?

  2. R-Goc commented on Aug 12, 2026

    @R-Goc
    Author

    Not too familiar with ASIO. Const_buffer in asio has a constructor that accepts a span. I assume string_view would satisfy this from looking at it but I didn't try. https://think-async.com/Asio/asio-1.38.2/doc/asio/reference/const_buffer/const_buffer/overload4.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions