]>
git.proxmox.com Git - ceph.git/blob - ceph/src/Beast/examples/websocket_echo.cpp
2 // Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #include "websocket_async_echo_server.hpp"
9 #include "websocket_sync_echo_server.hpp"
10 #include <boost/asio/io_service.hpp>
11 #include <boost/asio/signal_set.hpp>
14 /// Block until SIGINT or SIGTERM is received.
18 boost::asio::io_service ios
;
19 boost::asio::signal_set
signals(
20 ios
, SIGINT
, SIGTERM
);
22 [&](boost::system::error_code
const&, int)
30 using namespace beast::websocket
;
31 using endpoint_type
= boost::asio::ip::tcp::endpoint
;
32 using address_type
= boost::asio::ip::address
;
36 permessage_deflate pmd
;
37 pmd
.client_enable
= true;
38 pmd
.server_enable
= true;
41 websocket::async_echo_server s1
{&std::cout
, 1};
42 s1
.set_option(read_message_max
{64 * 1024 * 1024});
43 s1
.set_option(auto_fragment
{false});
45 s1
.open(endpoint_type
{
46 address_type::from_string("127.0.0.1"), 6000 }, ec
);
48 websocket::sync_echo_server s2
{&std::cout
};
49 s2
.set_option(read_message_max
{64 * 1024 * 1024});
50 s2
.set_option(auto_fragment
{false});
52 s2
.open(endpoint_type
{
53 address_type::from_string("127.0.0.1"), 6001 }, ec
);