#include <connection_basic.hpp>
|
| | connection_basic (boost::asio::ip::tcp::socket &&socket, boost::shared_ptr< connection_basic_shared_state > state, ssl_support_t ssl_support) |
| |
| | connection_basic (boost::asio::io_service &io_service, boost::shared_ptr< connection_basic_shared_state > state, ssl_support_t ssl_support) |
| |
| virtual | ~connection_basic () noexcept(false) |
| |
| connection_basic_shared_state & | get_state () noexcept |
| |
| | connection_basic (boost::asio::io_service &io_service, std::atomic< long > &ref_sock_count, std::atomic< long > &sock_number, ssl_support_t ssl) |
| |
| boost::asio::ip::tcp::socket & | socket () |
| |
| ssl_support_t | get_ssl_support () const |
| |
| void | disable_ssl () |
| |
| bool | handshake (boost::asio::ssl::stream_base::handshake_type type) |
| |
| template<typename MutableBufferSequence , typename ReadHandler > |
| void | async_read_some (const MutableBufferSequence &buffers, ReadHandler &&handler) |
| |
| template<typename ConstBufferSequence , typename WriteHandler > |
| void | async_write_some (const ConstBufferSequence &buffers, WriteHandler &&handler) |
| |
| template<typename ConstBufferSequence , typename WriteHandler > |
| void | async_write (const ConstBufferSequence &buffers, WriteHandler &&handler) |
| |
| void | do_send_handler_write (const void *ptr, size_t cb) |
| |
| void | do_send_handler_write_from_queue (const boost::system::error_code &e, size_t cb, int q_len) |
| |
| void | logger_handle_net_write (size_t size) |
| |
| void | logger_handle_net_read (size_t size) |
| |
| void | sleep_before_packet (size_t packet_size, int phase, int q_len) |
| |
Definition at line 101 of file connection_basic.hpp.
◆ connection_basic() [1/3]
Definition at line 132 of file connection_basic.cpp.
135 mI(
new connection_basic_pimpl(
"peer") ),
143 assert(m_state !=
nullptr);
147 ++(m_state->sock_count);
148 mI->m_peer_number = m_state->sock_number.fetch_add(1);
151 try { boost::system::error_code e; remote_addr_str =
socket().remote_endpoint(e).address().to_string(); }
catch(...){} ;
153 _note(
"Spawned connection #"<<
mI->m_peer_number<<
" to " << remote_addr_str <<
" currently we have sockets count:" << m_state->sock_count);
boost::asio::io_service::strand strand_
Strand to ensure the connection's handlers are not called concurrently.
boost::asio::ssl::stream< boost::asio::ip::tcp::socket > socket_
Socket for the connection.
ssl_support_t m_ssl_support
std::atomic< bool > m_was_shutdown
std::unique_ptr< connection_basic_pimpl > mI
boost::asio::ip::tcp::socket & socket()
volatile uint32_t m_want_close_connection
#define GET_IO_SERVICE(s)
const T & move(const T &t)
◆ connection_basic() [2/3]
Definition at line 156 of file connection_basic.cpp.
159 mI(
new connection_basic_pimpl(
"peer") ),
161 socket_(io_service, get_context(m_state.get())),
167 assert(m_state !=
nullptr);
169 ++(m_state->sock_count);
170 mI->m_peer_number = m_state->sock_number.fetch_add(1);
173 try { boost::system::error_code e; remote_addr_str =
socket().remote_endpoint(e).address().to_string(); }
catch(...){} ;
175 _note(
"Spawned connection #"<<
mI->m_peer_number<<
" to " << remote_addr_str <<
" currently we have sockets count:" << m_state->sock_count);
◆ ~connection_basic()
| epee::net_utils::connection_basic::~connection_basic |
( |
| ) |
|
|
virtualnoexcept |
Definition at line 178 of file connection_basic.cpp.
179 --(m_state->sock_count);
182 try { boost::system::error_code e; remote_addr_str =
socket().remote_endpoint(e).address().to_string(); }
catch(...){} ;
183 _note(
"Destructing connection #"<<
mI->m_peer_number <<
" to " << remote_addr_str);
◆ connection_basic() [3/3]
| epee::net_utils::connection_basic::connection_basic |
( |
boost::asio::io_service & |
io_service, |
|
|
std::atomic< long > & |
ref_sock_count, |
|
|
std::atomic< long > & |
sock_number, |
|
|
ssl_support_t |
ssl |
|
) |
| |
◆ async_read_some()
template<typename MutableBufferSequence , typename ReadHandler >
| void epee::net_utils::connection_basic::async_read_some |
( |
const MutableBufferSequence & |
buffers, |
|
|
ReadHandler && |
handler |
|
) |
| |
|
inline |
Definition at line 142 of file connection_basic.hpp.
145 socket_.async_read_some(buffers, std::forward<ReadHandler>(handler));
147 socket().async_read_some(buffers, std::forward<ReadHandler>(handler));
◆ async_write()
template<typename ConstBufferSequence , typename WriteHandler >
| void epee::net_utils::connection_basic::async_write |
( |
const ConstBufferSequence & |
buffers, |
|
|
WriteHandler && |
handler |
|
) |
| |
|
inline |
Definition at line 160 of file connection_basic.hpp.
163 boost::asio::async_write(
socket_, buffers, std::forward<WriteHandler>(handler));
165 boost::asio::async_write(
socket(), buffers, std::forward<WriteHandler>(handler));
◆ async_write_some()
template<typename ConstBufferSequence , typename WriteHandler >
| void epee::net_utils::connection_basic::async_write_some |
( |
const ConstBufferSequence & |
buffers, |
|
|
WriteHandler && |
handler |
|
) |
| |
|
inline |
Definition at line 151 of file connection_basic.hpp.
154 socket_.async_write_some(buffers, std::forward<WriteHandler>(handler));
156 socket().async_write_some(buffers, std::forward<WriteHandler>(handler));
◆ disable_ssl()
| void epee::net_utils::connection_basic::disable_ssl |
( |
| ) |
|
|
inline |
◆ do_send_handler_write()
| void epee::net_utils::connection_basic::do_send_handler_write |
( |
const void * |
ptr, |
|
|
size_t |
cb |
|
) |
| |
Definition at line 266 of file connection_basic.cpp.
268 MTRACE(
"handler_write (direct) - before ASIO write, for packet="<<cb<<
" B (after sleep)");
◆ do_send_handler_write_from_queue()
| void epee::net_utils::connection_basic::do_send_handler_write_from_queue |
( |
const boost::system::error_code & |
e, |
|
|
size_t |
cb, |
|
|
int |
q_len |
|
) |
| |
Definition at line 271 of file connection_basic.cpp.
273 MTRACE(
"handler_write (after write, from queue="<<q_len<<
") - before ASIO write, for packet="<<cb<<
" B (after sleep)");
◆ get_rate_down_limit()
| uint64_t epee::net_utils::connection_basic::get_rate_down_limit |
( |
| ) |
|
|
static |
Definition at line 216 of file connection_basic.cpp.
virtual network_speed_kbps get_target_speed()=0
static boost::mutex m_lock_get_global_throttle_in
static i_network_throttle & get_global_throttle_in()
singleton ; for friend class ; caller MUST use proper locks! like m_lock_get_global_throttle_in
unsigned __int64 uint64_t
#define CRITICAL_REGION_LOCAL(x)
◆ get_rate_up_limit()
| uint64_t epee::net_utils::connection_basic::get_rate_up_limit |
( |
| ) |
|
|
static |
Definition at line 207 of file connection_basic.cpp.
static i_network_throttle & get_global_throttle_out()
ditto ; use lock ... use m_lock_get_global_throttle_out obviously
static boost::mutex m_lock_get_global_throttle_out
◆ get_sleep_time()
| double epee::net_utils::connection_basic::get_sleep_time |
( |
size_t |
cb | ) |
|
|
static |
Definition at line 282 of file connection_basic.cpp.
283 CRITICAL_REGION_LOCAL(epee::net_utils::network_throttle_manager::network_throttle_manager::m_lock_get_global_throttle_out);
virtual network_time_seconds get_sleep_time(size_t packet_size) const =0
◆ get_ssl_support()
| ssl_support_t epee::net_utils::connection_basic::get_ssl_support |
( |
| ) |
const |
|
inline |
◆ get_state()
- Returns
shared_state object passed in construction (ptr never changes).
Definition at line 128 of file connection_basic.hpp.
◆ get_tos_flag()
| int epee::net_utils::connection_basic::get_tos_flag |
( |
| ) |
|
|
static |
◆ handshake()
| bool epee::net_utils::connection_basic::handshake |
( |
boost::asio::ssl::stream_base::handshake_type |
type | ) |
|
|
inline |
◆ logger_handle_net_read()
| void epee::net_utils::connection_basic::logger_handle_net_read |
( |
size_t |
size | ) |
|
◆ logger_handle_net_write()
| void epee::net_utils::connection_basic::logger_handle_net_write |
( |
size_t |
size | ) |
|
◆ save_limit_to_file()
| void epee::net_utils::connection_basic::save_limit_to_file |
( |
int |
limit | ) |
|
|
static |
◆ set_rate_down_limit()
| void epee::net_utils::connection_basic::set_rate_down_limit |
( |
uint64_t |
limit | ) |
|
|
static |
Definition at line 194 of file connection_basic.cpp.
static void save_limit_to_file(int limit)
for dr-electroneum
virtual void set_target_speed(network_speed_kbps target)=0
static boost::mutex m_lock_get_global_throttle_inreq
static i_network_throttle & get_global_throttle_inreq()
ditto ; use lock ... use m_lock_get_global_throttle_inreq obviously
◆ set_rate_up_limit()
| void epee::net_utils::connection_basic::set_rate_up_limit |
( |
uint64_t |
limit | ) |
|
|
static |
◆ set_save_graph()
| void epee::net_utils::connection_basic::set_save_graph |
( |
bool |
save_graph | ) |
|
|
static |
◆ set_tos_flag()
| void epee::net_utils::connection_basic::set_tos_flag |
( |
int |
tos | ) |
|
|
static |
◆ sleep_before_packet()
| void epee::net_utils::connection_basic::sleep_before_packet |
( |
size_t |
packet_size, |
|
|
int |
phase, |
|
|
int |
q_len |
|
) |
| |
Definition at line 236 of file connection_basic.cpp.
241 _dbg2(
"m_was_shutdown - so abort sleep");
252 long int ms = (
long int)(delay * 1000);
253 MTRACE(
"Sleeping in " << __FUNCTION__ <<
" for " << ms <<
" ms before packet_size="<<packet_size);
254 boost::this_thread::sleep(boost::posix_time::milliseconds( ms ) );
virtual network_time_seconds get_sleep_time_after_tick(size_t packet_size)=0
virtual void handle_trafic_exact(size_t packet_size)=0
◆ socket()
| boost::asio::ip::tcp::socket& epee::net_utils::connection_basic::socket |
( |
| ) |
|
|
inline |
◆ m_is_multithreaded
| volatile bool epee::net_utils::connection_basic::m_is_multithreaded |
◆ m_send_que
| std::list<std::string> epee::net_utils::connection_basic::m_send_que |
◆ m_send_que_lock
◆ m_ssl_support
◆ m_want_close_connection
| volatile uint32_t epee::net_utils::connection_basic::m_want_close_connection |
◆ m_was_shutdown
| std::atomic<bool> epee::net_utils::connection_basic::m_was_shutdown |
◆ mI
◆ socket_
| boost::asio::ssl::stream<boost::asio::ip::tcp::socket> epee::net_utils::connection_basic::socket_ |
◆ strand_
| boost::asio::io_service::strand epee::net_utils::connection_basic::strand_ |
Strand to ensure the connection's handlers are not called concurrently.
Definition at line 115 of file connection_basic.hpp.
The documentation for this class was generated from the following files: