Login / Register  0 items | $0.00 NewWhat is KVR? Submit News Advertise
User avatar
thevinn
KVRian
 
775 posts since 30 Nov, 2008

Postby thevinn; Tue Jun 13, 2017 2:52 pm Beast: A NEW library needs your Help (from the maker of DSPFilters)

Hi there, my name is Vinnie and you might know me from my popular repository "DSPFilters." I've been hard at work on a brand new open-source library called "Beast":

Beast is a C++ header-only library serving as a foundation for writing interoperable networking libraries by providing low-level HTTP/1, WebSocket, and networking protocol vocabulary types and algorithms using the consistent asynchronous model of Boost.Asio.

Beast is scheduled for a Boost formal review on July 1st and I'm making a plea for your help, if you could please visit the repository and press "Star" in the top right, that will help elevate Beast in the rankings and generate new users:

https://github.com/vinniefalco/Beast/

This in turn will lead to more bug reports (oops!) but that's okay because every bug I squash means one less bug that you might encounter if you decide to use this library some day!

What's this have to do with DSP and Plugin Development? Umm...err... well, maybe someone will want to grab a resource from a web server using HTTP GET (check a license, or a news file perhaps?) Or maybe someone will use the WebSocket module to create a plugin that lets musicians collaborate and play instruments over the Internet! Who knows?

Comments / criticisms about Beast are welcomed!
User avatar
lorcan
KVRist
 
108 posts since 25 Sep, 2001, from Paris, France

Postby lorcan; Tue Jun 13, 2017 3:25 pm Re: Beast: A NEW library needs your Help (from the maker of DSPFilters)

Done ! Thumbs up for your work and hope it gets accepted into boost.

I'm currently using boost.asio + openssl to do a simple update check in my plugins (check the server if a new version is available).
Do you reckon there would there be any benefit in switching over to Beast in this case ?
User avatar
thevinn
KVRian
 
775 posts since 30 Nov, 2008

Postby thevinn; Tue Jun 13, 2017 3:40 pm Re: Beast: A NEW library needs your Help (from the maker of DSPFilters)

lorcan wrote:I'm currently using boost.asio + openssl to do a simple update check in my plugins (check the server if a new version is available).
Do you reckon there would there be any benefit in switching over to Beast in this case ?


Thanks! If you already have something working, well there's a lot to be said for just sticking with what is already working. Adding another dependency to your plugin would increase the complexity, you have to weigh that against the benefit. Since you control the server, its unlikely that your server will deliver an exploit or malformed HTTP to the plugin. Of course, if Beast makes it into Boost then you could likely simplify some code. Here's what it looks like to retrieve a resource using OpenSSL and Beast:

Code: Select all
int main()
{
    using boost::asio::connect;
    using socket = boost::asio::ip::tcp::socket;
    using resolver = boost::asio::ip::tcp::resolver;
    using io_service = boost::asio::io_service;
    namespace ssl = boost::asio::ssl;

    // Normal boost::asio setup
    std::string const host = "github.com";
    io_service ios;
    resolver r{ios};
    socket sock{ios};
    connect(sock, r.resolve(resolver::query{host, "https"}));

    // Perform SSL handshaking
    ssl::context ctx{ssl::context::sslv23};
    ssl::stream<socket&> stream{sock, ctx};
    stream.set_verify_mode(ssl::verify_none);
    stream.handshake(ssl::stream_base::client);

    // Send HTTP request over SSL using Beast
    beast::http::request<beast::http::string_body> req;
    req.method(beast::http::verb::get);
    req.target("/");
    req.version = 11;
    req.insert(beast::http::field::host, host + ":" +
        boost::lexical_cast<std::string>(sock.remote_endpoint().port()));
    req.insert(beast::http::field::user_agent, "Beast");
    req.prepare();
    beast::http::write(stream, req);

    // Receive and print HTTP response using Beast
    beast::flat_buffer b;
    beast::http::response<beast::http::dynamic_body> resp;
    beast::http::read(stream, b, resp);
    std::cout << resp;

    // Shut down SSL on the stream
    boost::system::error_code ec;
    stream.shutdown(ec);
    if(ec && ec != boost::asio::error::eof)
        std::cout << "error: " << ec.message();
}
whichdokta
KVRer
 
5 posts since 30 Apr, 2012

Postby whichdokta; Wed Jun 14, 2017 12:52 am Re: Beast: A NEW library needs your Help (from the maker of DSPFilters)

Done, thank you for your past & present work Vinnie!
Miles1981
KVRian
 
1251 posts since 26 Apr, 2004, from UK

Postby Miles1981; Wed Jun 14, 2017 6:31 am Re: Beast: A NEW library needs your Help (from the maker of DSPFilters)

What are the differences with ASIO? Seems like there are some overlaps between the two solutions?
User avatar
thevinn
KVRian
 
775 posts since 30 Nov, 2008

Postby thevinn; Thu Jun 15, 2017 1:00 am Re: Beast: A NEW library needs your Help (from the maker of DSPFilters)

Hmm..Asio is just a raw socket, while Beast actually speaks the HTTP and WebSocket protocols. Beast also provides a container for holding the message. This container is flexible and customizable (see the docs).

Moderator: Moderators (Main)

Return to DSP and Plug-in Development