8 #ifndef DIAG_CLIENT_LIB_LIB_BOOST_SUPPORT_SOCKET_TCP_TCP_CLIENT_H_
9 #define DIAG_CLIENT_LIB_LIB_BOOST_SUPPORT_SOCKET_TCP_TCP_CLIENT_H_
11 #include <boost/asio.hpp>
13 #include <string_view>
95 using Tcp = boost::asio::ip::tcp;
Class used to create a tcp socket for handling transmission and reception of tcp message from driver.
boost::system::error_code TcpErrorCodeType
Type alias for tcp error codes.
std::uint16_t local_port_num_
Store local port number.
std::function< void(TcpMessagePtr)> TcpHandlerRead
Tcp function template used for reception.
std::string local_ip_address_
Store local ip address.
TcpSocket tcp_socket_
Store tcp socket.
std::mutex mutex_
mutex to lock critical section
core_type::Result< void, TcpErrorCode > DisconnectFromHost()
Function to Disconnect from host.
TcpHandlerRead tcp_handler_read_
Store the handler.
boost::asio::io_context io_context_
boost io context
core_type::Result< void, TcpErrorCode > Destroy()
Function to destroy the socket.
Tcp::socket TcpSocket
Type alias for tcp socket.
core_type::Result< void, TcpErrorCode > Open()
Function to Open the socket.
std::atomic_bool exit_request_
Flag to terminate the thread.
TcpErrorCode
Tcp error code.
std::atomic_bool running_
Flag to start the thread.
std::condition_variable cond_var_
Conditional variable to block the thread.
~TcpClientSocket()
Destruct an instance of TcpClientSocket.
boost::asio::ip::tcp Tcp
Type alias for tcp protocol.
core_type::Result< void, TcpErrorCode > Transmit(TcpMessageConstPtr tcp_message)
Function to trigger transmission.
void HandleMessage()
Function to handle the reception of tcp message.
core_type::Result< void, TcpErrorCode > ConnectToHost(std::string_view host_ip_address, std::uint16_t host_port_num)
Function to connect to remote ip address and port number.
TcpClientSocket(std::string_view local_ip_address, std::uint16_t local_port_num, TcpHandlerRead tcp_handler_read)
Constructs an instance of TcpClientSocket.
std::thread thread_
The thread itself.
boost::asio::ip::address TcpIpAddress
Type alias for tcp ip address.
Class type to contains a value (of type ValueType), or an error (of type ErrorType)
std::unique_ptr< const TcpMessage > TcpMessageConstPtr
The unique pointer to const TcpMessage.
std::unique_ptr< TcpMessage > TcpMessagePtr
The unique pointer to TcpMessage.