Files
beast/test/websocket/websocket_echo.cpp
T

45 lines
1.3 KiB
C++
Raw Normal View History

2016-05-07 17:06:46 -04:00
//
// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
2016-02-25 16:17:19 -05:00
2016-08-26 09:11:06 -04:00
#include "websocket_async_echo_server.hpp"
#include "websocket_sync_echo_server.hpp"
2016-05-07 07:08:21 -04:00
#include <beast/test/sig_wait.hpp>
2016-11-02 17:34:53 -04:00
#include <iostream>
2016-02-25 16:17:19 -05:00
int main()
{
2016-10-24 18:41:25 -04:00
using namespace beast::websocket;
2016-02-25 16:17:19 -05:00
using endpoint_type = boost::asio::ip::tcp::endpoint;
using address_type = boost::asio::ip::address;
2016-11-02 17:34:53 -04:00
try
{
2017-01-27 20:14:47 -05:00
permessage_deflate pmd;
pmd.client_enable = true;
pmd.server_enable = true;
2016-10-24 18:41:25 -04:00
beast::error_code ec;
async_echo_server s1{nullptr, 1};
s1.open(endpoint_type{
2016-11-02 17:34:53 -04:00
address_type::from_string("127.0.0.1"), 6000 }, ec);
2016-10-24 18:41:25 -04:00
s1.set_option(read_message_max{64 * 1024 * 1024});
s1.set_option(auto_fragment{false});
2017-01-27 20:14:47 -05:00
s1.set_option(pmd);
2016-02-25 16:17:19 -05:00
2016-10-24 18:41:25 -04:00
beast::websocket::sync_echo_server s2(&std::cout, endpoint_type{
2016-11-02 17:34:53 -04:00
address_type::from_string("127.0.0.1"), 6001 });
2016-10-24 18:41:25 -04:00
s2.set_option(read_message_max{64 * 1024 * 1024});
2017-01-27 20:14:47 -05:00
s2.set_option(pmd);
2016-02-25 16:17:19 -05:00
2016-11-02 17:34:53 -04:00
beast::test::sig_wait();
}
catch(std::exception const& e)
{
std::cout << "Error: " << e.what() << std::endl;
}
2016-02-25 16:17:19 -05:00
}