|
Diag-Client-Lib
|
Class used to create a tcp socket for handling transmission and reception of tcp message from driver. More...
#include <tls_socket.h>
Public Types | |
| enum class | SocketError : std::uint8_t { kOpenFailed , kBindingFailed , kRemoteDisconnected , kTlsHandshakeFailed , kGenericError } |
| Socket error code. More... | |
| using | TcpMessage = boost_support::message::tcp::TcpMessage |
| Type alias for Tcp message. More... | |
| using | TcpMessagePtr = boost_support::message::tcp::TcpMessagePtr |
| Type alias for Tcp message pointer. More... | |
| using | TcpMessageConstPtr = boost_support::message::tcp::TcpMessageConstPtr |
| Type alias for Tcp message const pointer. More... | |
| using | Tcp = boost::asio::ip::tcp |
| Type alias for tcp protocol. More... | |
| using | TcpSocket = Tcp::socket |
| Type alias for tcp socket. More... | |
Public Member Functions | |
| TlsSocket (std::string_view local_ip_address, std::uint16_t local_port_num, TlsContext &tls_context, IoContext &io_context) noexcept | |
| Constructs an instance of TcpSocket. More... | |
| TlsSocket (TcpSocket tcp_socket, TlsContext &tls_context) noexcept | |
| Constructs an instance of TcpSocket. More... | |
| TlsSocket (const TlsSocket &other) noexcept=delete | |
| Deleted copy assignment and copy constructor. More... | |
| TlsSocket & | operator= (const TlsSocket &other) noexcept=delete |
| TlsSocket & | operator= (TlsSocket &&other) noexcept |
| Move assignment. More... | |
| TlsSocket (TlsSocket &&other) noexcept | |
| Move constructor. More... | |
| ~TlsSocket () noexcept | |
| Destruct an instance of TcpSocket. More... | |
| core_type::Result< void, SocketError > | Open () noexcept |
| Function to open and bind the socket to provided ip address & port. More... | |
| core_type::Result< void, SocketError > | Connect (std::string_view host_ip_address, std::uint16_t host_port_num) noexcept |
| Function to connect to remote ip address and port number. More... | |
| core_type::Result< void, SocketError > | Disconnect () noexcept |
| Function to Disconnect from host. More... | |
| core_type::Result< void, SocketError > | Transmit (TcpMessageConstPtr tcp_message) noexcept |
| Function to trigger transmission. More... | |
| core_type::Result< TcpMessagePtr, SocketError > | Read () noexcept |
| Function to read message from socket. More... | |
| core_type::Result< void, SocketError > | Close () noexcept |
| Function to destroy the socket. More... | |
Private Types | |
| using | TcpIpAddress = boost::asio::ip::address |
| Type alias for tcp ip address. More... | |
| using | TcpErrorCodeType = boost::system::error_code |
| Type alias for tcp error codes. More... | |
| using | SslStream = boost::asio::ssl::stream< Tcp::socket > |
| Type alias for tcp socket. More... | |
Private Member Functions | |
| SslStream::lowest_layer_type & | GetNativeTcpSocket () |
| Function to get the native tcp socket under tls socket. More... | |
Private Attributes | |
| SslStream | ssl_stream_ |
| Store the underlying tcp socket. More... | |
| Tcp::endpoint | local_endpoint_ |
| Store the local endpoints. More... | |
Class used to create a tcp socket for handling transmission and reception of tcp message from driver.
Definition at line 25 of file tls_socket.h.
|
private |
Type alias for tcp socket.
Definition at line 161 of file tls_socket.h.
| using boost_support::socket::tls::TlsSocket::Tcp = boost::asio::ip::tcp |
Type alias for tcp protocol.
Definition at line 56 of file tls_socket.h.
|
private |
Type alias for tcp error codes.
Definition at line 156 of file tls_socket.h.
|
private |
Type alias for tcp ip address.
Definition at line 151 of file tls_socket.h.
Type alias for Tcp message.
Definition at line 41 of file tls_socket.h.
| using boost_support::socket::tls::TlsSocket::TcpMessageConstPtr = boost_support::message::tcp::TcpMessageConstPtr |
Type alias for Tcp message const pointer.
Definition at line 51 of file tls_socket.h.
| using boost_support::socket::tls::TlsSocket::TcpMessagePtr = boost_support::message::tcp::TcpMessagePtr |
Type alias for Tcp message pointer.
Definition at line 46 of file tls_socket.h.
| using boost_support::socket::tls::TlsSocket::TcpSocket = Tcp::socket |
Type alias for tcp socket.
Definition at line 61 of file tls_socket.h.
|
strong |
Socket error code.
| Enumerator | |
|---|---|
| kOpenFailed | |
| kBindingFailed | |
| kRemoteDisconnected | |
| kTlsHandshakeFailed | |
| kGenericError | |
Definition at line 30 of file tls_socket.h.
|
noexcept |
Constructs an instance of TcpSocket.
| [in] | local_ip_address | The local ip address |
| [in] | local_port_num | The local port number |
| [in] | io_context | The I/O context required to create socket |
Definition at line 19 of file tls_socket.cpp.
|
noexcept |
Constructs an instance of TcpSocket.
| [in] | socket | The socket |
Definition at line 24 of file tls_socket.cpp.
|
deletenoexcept |
Deleted copy assignment and copy constructor.
|
noexcept |
|
defaultnoexcept |
Destruct an instance of TcpSocket.
|
noexcept |
Function to destroy the socket.
Definition at line 178 of file tls_socket.cpp.
References GetNativeTcpSocket(), and kGenericError.

|
noexcept |
Function to connect to remote ip address and port number.
| [in] | host_ip_address | The host ip address |
| [in] | host_port_num | The host port number |
Definition at line 95 of file tls_socket.cpp.
References FILE_NAME, and boost_support::common::logger::LibBoostLogger::GetLibBoostLogger().

|
noexcept |
Function to Disconnect from host.
Definition at line 131 of file tls_socket.cpp.
References FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), kGenericError, and ssl_stream_.

|
private |
Function to get the native tcp socket under tls socket.
Definition at line 256 of file tls_socket.cpp.
References ssl_stream_.
Referenced by Close(), and Read().

|
noexcept |
Function to open and bind the socket to provided ip address & port.
Definition at line 54 of file tls_socket.cpp.
References FILE_NAME, and boost_support::common::logger::LibBoostLogger::GetLibBoostLogger().

|
deletenoexcept |
|
noexcept |
Function to read message from socket.
Definition at line 191 of file tls_socket.cpp.
References FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), GetNativeTcpSocket(), boost_support::message::tcp::kDoipheadrSize, kRemoteDisconnected, and ssl_stream_.

|
noexcept |
Function to trigger transmission.
| [in] | tcp_message | The tcp message to be transmitted |
Definition at line 152 of file tls_socket.cpp.
References FILE_NAME, and boost_support::common::logger::LibBoostLogger::GetLibBoostLogger().

|
private |
Store the local endpoints.
Definition at line 171 of file tls_socket.h.
|
private |
Store the underlying tcp socket.
Definition at line 166 of file tls_socket.h.
Referenced by Disconnect(), GetNativeTcpSocket(), and Read().