NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
endpoint.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015, Peter Thorson. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
6
* * Redistributions of source code must retain the above copyright
7
* notice, this list of conditions and the following disclaimer.
8
* * Redistributions in binary form must reproduce the above copyright
9
* notice, this list of conditions and the following disclaimer in the
10
* documentation and/or other materials provided with the distribution.
11
* * Neither the name of the WebSocket++ Project nor the
12
* names of its contributors may be used to endorse or promote products
13
* derived from this software without specific prior written permission.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
19
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
*
26
*/
27
//#define BOOST_TEST_DYN_LINK
28
#define BOOST_TEST_MODULE endpoint
29
#include <boost/test/unit_test.hpp>
30
31
#include <iostream>
32
#include <sstream>
33
34
#include <
websocketpp/config/asio.hpp
>
35
#include <
websocketpp/server.hpp
>
36
37
BOOST_AUTO_TEST_CASE
( construct_server_iostream ) {
38
websocketpp::server<websocketpp::config::core>
s;
39
}
40
41
BOOST_AUTO_TEST_CASE
( construct_server_asio_plain ) {
42
websocketpp::server<websocketpp::config::asio>
s;
43
}
44
45
BOOST_AUTO_TEST_CASE
( construct_server_asio_tls ) {
46
websocketpp::server<websocketpp::config::asio_tls>
s;
47
}
48
49
BOOST_AUTO_TEST_CASE
( initialize_server_asio ) {
50
websocketpp::server<websocketpp::config::asio>
s;
51
s.init_asio();
52
}
53
54
BOOST_AUTO_TEST_CASE
( initialize_server_asio_external ) {
55
websocketpp::server<websocketpp::config::asio>
s;
56
boost::asio::io_service ios;
57
s.init_asio(&ios);
58
}
59
60
#ifdef _WEBSOCKETPP_MOVE_SEMANTICS_
61
BOOST_AUTO_TEST_CASE
( move_construct_server_core ) {
62
websocketpp::server<websocketpp::config::core>
s1;
63
64
websocketpp::server<websocketpp::config::core>
s2(
std::move
(s1));
65
}
66
67
/*
68
// temporary disable because library doesn't pass
69
BOOST_AUTO_TEST_CASE( emplace ) {
70
std::stringstream out1;
71
std::stringstream out2;
72
73
std::vector<websocketpp::server<websocketpp::config::asio_tls>> v;
74
75
v.emplace_back();
76
v.emplace_back();
77
78
v[0].get_alog().set_ostream(&out1);
79
v[0].get_alog().set_ostream(&out2);
80
81
v[0].get_alog().write(websocketpp::log::alevel::app,"devel0");
82
v[1].get_alog().write(websocketpp::log::alevel::app,"devel1");
83
BOOST_CHECK( out1.str().size() > 0 );
84
BOOST_CHECK( out2.str().size() > 0 );
85
}*/
86
87
#endif // _WEBSOCKETPP_MOVE_SEMANTICS_
88
89
struct
endpoint_extension
{
90
endpoint_extension
() :
extension_value
(5) {}
91
92
int
extension_method
() {
93
return
extension_value
;
94
}
95
96
bool
is_server
()
const
{
97
return
false
;
98
}
99
100
int
extension_value
;
101
};
102
103
struct
stub_config
:
public
websocketpp::config::core
{
104
typedef
core::concurrency_type
concurrency_type
;
105
106
typedef
core::request_type
request_type
;
107
typedef
core::response_type
response_type
;
108
109
typedef
core::message_type
message_type
;
110
typedef
core::con_msg_manager_type
con_msg_manager_type
;
111
typedef
core::endpoint_msg_manager_type
endpoint_msg_manager_type
;
112
113
typedef
core::alog_type
alog_type
;
114
typedef
core::elog_type
elog_type
;
115
116
typedef
core::rng_type
rng_type
;
117
118
typedef
core::transport_type
transport_type
;
119
120
typedef
endpoint_extension
endpoint_base
;
121
};
122
123
BOOST_AUTO_TEST_CASE
( endpoint_extensions ) {
124
websocketpp::server<stub_config>
s;
125
126
BOOST_CHECK_EQUAL( s.extension_value, 5 );
127
BOOST_CHECK_EQUAL( s.extension_method(), 5 );
128
129
BOOST_CHECK( s.
is_server
() );
130
}
131
132
BOOST_AUTO_TEST_CASE
( listen_after_listen_failure ) {
133
using
websocketpp::transport::asio::error::make_error_code
;
134
using
websocketpp::transport::asio::error::pass_through
;
135
136
websocketpp::server<websocketpp::config::asio>
server1;
137
websocketpp::server<websocketpp::config::asio>
server2;
138
139
websocketpp::lib::error_code ec;
140
141
server1.init_asio();
142
server2.init_asio();
143
144
boost::asio::ip::tcp::endpoint ep1(boost::asio::ip::address::from_string(
"127.0.0.1"
), 12345);
145
boost::asio::ip::tcp::endpoint ep2(boost::asio::ip::address::from_string(
"127.0.0.1"
), 23456);
146
147
server1.listen(ep1, ec);
148
BOOST_CHECK(!ec);
149
150
// This should return some sort of problem. Usually either "pass through" or
151
// a more specific address in use error. It is hard to capture the full range
152
// of 'correctly wrong' values.
153
server2.listen(ep1, ec);
154
BOOST_REQUIRE(ec);
155
156
server2.listen(ep2, ec);
157
BOOST_CHECK(!ec);
158
}
endpoint_extension::endpoint_extension
endpoint_extension()
Definition:
endpoint.cpp:90
stub_config::con_msg_manager_type
core::con_msg_manager_type con_msg_manager_type
Definition:
endpoint.cpp:110
websocketpp::transport::asio::error::make_error_code
lib::error_code make_error_code(error::value e)
Create an error code with the given value and the asio transport category.
Definition:
base.hpp:217
stub_config::message_type
core::message_type message_type
Definition:
endpoint.cpp:109
endpoint_extension::extension_method
int extension_method()
Definition:
endpoint.cpp:92
nonstd::optional_lite::std11::move
T & move(T &t)
Definition:
optional-lite.hpp:472
stub_config::rng_type
core::rng_type rng_type
Definition:
endpoint.cpp:116
stub_config::transport_type
core::transport_type transport_type
Definition:
endpoint.cpp:118
endpoint_extension
Definition:
endpoint.cpp:89
con_msg_manager_type
stub_config::con_msg_manager_type con_msg_manager_type
Definition:
hybi13.cpp:89
stub_config::elog_type
core::elog_type elog_type
Definition:
endpoint.cpp:114
asio.hpp
stub_config::endpoint_msg_manager_type
core::endpoint_msg_manager_type endpoint_msg_manager_type
Definition:
endpoint.cpp:111
endpoint_extension::extension_value
int extension_value
Definition:
endpoint.cpp:100
websocketpp::endpoint< connection< config >, config >::is_server
bool is_server() const
Returns whether or not this endpoint is a server.
Definition:
endpoint.hpp:205
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(construct_server_iostream)
Definition:
endpoint.cpp:37
websocketpp::server
Server endpoint role based on the given config.
Definition:
server_endpoint.hpp:44
websocketpp::transport::asio::error::pass_through
there was an error in the underlying transport library
Definition:
base.hpp:171
stub_config::alog_type
core::alog_type alog_type
Definition:
endpoint.cpp:113
stub_config::concurrency_type
core::concurrency_type concurrency_type
Definition:
endpoint.cpp:104
stub_config::request_type
core::request_type request_type
Definition:
endpoint.cpp:106
stub_config::endpoint_base
endpoint_extension endpoint_base
Definition:
endpoint.cpp:120
stub_config::response_type
core::response_type response_type
Definition:
endpoint.cpp:107
endpoint_extension::is_server
bool is_server() const
Definition:
endpoint.cpp:96
server.hpp
stub_config
Definition:
connection.cpp:65
websocketpp::config::core
Server config with iostream transport.
Definition:
core.hpp:68
ndnSIM
NFD
websocketpp
test
endpoint
endpoint.cpp
Generated on Fri May 6 2022 12:34:14 for ndnSIM by
1.8.13