Diag-Client-Lib
|
Tcp Server connection class to create connection with client. More...
#include <tls_server_.h>
Public Types | |
enum class | TcpErrorCode : std::uint8_t { kOpenFailed , kBindingFailed , kGenericError } |
Tcp error code. More... | |
using | TcpHandlerRead = std::function< void(message::tcp::TcpMessagePtr)> |
Tcp function template used for reception. More... | |
using | Tcp = boost::asio::ip::tcp |
Type alias for tcp protocol. More... | |
using | TcpSocket = Tcp::socket |
Type alias for tcp socket. More... | |
using | TlsStream = boost::asio::ssl::stream< TcpSocket > |
Type alias for tls stream wrapping tcp socket. More... | |
Public Member Functions | |
TcpServerConnection (TlsStream tls_socket, TcpHandlerRead tcp_handler_read) | |
Constructs an instance of TcpServerConnection. More... | |
~TcpServerConnection ()=default | |
Destruct an instance of TcpServerConnection. More... | |
TcpServerConnection (TcpServerConnection &&) noexcept=default | |
Default move ctor and assignment operator. More... | |
TcpServerConnection & | operator= (TcpServerConnection &&) noexcept=default |
TcpServerConnection (TcpServerConnection const &)=delete | |
Deleted copy ctor and assignment operator. More... | |
TcpServerConnection & | operator= (TcpServerConnection const &)=delete |
core_type::Result< void, TcpErrorCode > | Transmit (message::tcp::TcpMessageConstPtr tcp_message) |
Function to trigger transmission. More... | |
bool | TryReceivingMessage () |
Function to initiate reception of tcp message. More... | |
core_type::Result< void, TcpErrorCode > | Shutdown () |
Function to shutdown the socket. More... | |
Private Member Functions | |
TlsStream::lowest_layer_type & | GetNativeTcpSocket () |
Function to get the native tcp socket under tls socket. More... | |
Private Attributes | |
TlsStream | tls_socket_ |
Store ssl socket. More... | |
TcpHandlerRead | tcp_handler_read_ |
Store the handler. More... | |
Tcp Server connection class to create connection with client.
Definition at line 28 of file tls_server_.h.
using boost_support::socket::tcp::TcpServerConnection::Tcp = boost::asio::ip::tcp |
Type alias for tcp protocol.
Definition at line 43 of file tls_server_.h.
using boost_support::socket::tcp::TcpServerConnection::TcpHandlerRead = std::function<void(message::tcp::TcpMessagePtr)> |
Tcp function template used for reception.
Definition at line 38 of file tls_server_.h.
using boost_support::socket::tcp::TcpServerConnection::TcpSocket = Tcp::socket |
Type alias for tcp socket.
Definition at line 48 of file tls_server_.h.
using boost_support::socket::tcp::TcpServerConnection::TlsStream = boost::asio::ssl::stream<TcpSocket> |
Type alias for tls stream wrapping tcp socket.
Definition at line 53 of file tls_server_.h.
|
strong |
Tcp error code.
Enumerator | |
---|---|
kOpenFailed | |
kBindingFailed | |
kGenericError |
Definition at line 33 of file tls_server_.h.
boost_support::socket::tcp::TcpServerConnection::TcpServerConnection | ( | TlsStream | tls_socket, |
TcpHandlerRead | tcp_handler_read | ||
) |
Constructs an instance of TcpServerConnection.
[in] | io_context | The local ip address |
[in] | tcp_handler_read | The handler to send received data to user |
Definition at line 65 of file tls_server_.cpp.
|
default |
Destruct an instance of TcpServerConnection.
|
defaultnoexcept |
Default move ctor and assignment operator.
|
delete |
Deleted copy ctor and assignment operator.
|
private |
Function to get the native tcp socket under tls socket.
Definition at line 69 of file tls_server_.cpp.
References tls_socket_.
Referenced by Shutdown(), Transmit(), and TryReceivingMessage().
|
defaultnoexcept |
|
delete |
core_type::Result< void, TcpServerConnection::TcpErrorCode > boost_support::socket::tcp::TcpServerConnection::Shutdown | ( | ) |
Function to shutdown the socket.
Definition at line 163 of file tls_server_.cpp.
References FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), GetNativeTcpSocket(), kGenericError, and tls_socket_.
core_type::Result< void, TcpServerConnection::TcpErrorCode > boost_support::socket::tcp::TcpServerConnection::Transmit | ( | message::tcp::TcpMessageConstPtr | tcp_message | ) |
Function to trigger transmission.
[in] | tcp_message | The tcp message to be transmitted |
Definition at line 73 of file tls_server_.cpp.
References FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), GetNativeTcpSocket(), kGenericError, and tls_socket_.
bool boost_support::socket::tcp::TcpServerConnection::TryReceivingMessage | ( | ) |
Function to initiate reception of tcp message.
Definition at line 100 of file tls_server_.cpp.
References FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), GetNativeTcpSocket(), boost_support::message::tcp::kDoipheadrSize, tcp_handler_read_, and tls_socket_.
|
private |
Store the handler.
Definition at line 110 of file tls_server_.h.
Referenced by TryReceivingMessage().
|
private |
Store ssl socket.
Definition at line 105 of file tls_server_.h.
Referenced by GetNativeTcpSocket(), Shutdown(), Transmit(), and TryReceivingMessage().