| 
    Diag-Client-Lib
    
   | 
 
Class to provide implementation of tcp client. More...

Public Member Functions | |
| TcpClientImpl (std::string_view client_name, std::string_view local_ip_address, std::uint16_t local_port_num) noexcept | |
| Constructs an instance of TcpClientImpl.  More... | |
| TcpClientImpl (const TcpClientImpl &other) noexcept=delete | |
| Deleted copy assignment and copy constructor.  More... | |
| TcpClientImpl & | operator= (const TcpClientImpl &other) noexcept=delete | 
| TcpClientImpl (TcpClientImpl &&other) noexcept=delete | |
| Deleted move assignment and move constructor.  More... | |
| TcpClientImpl & | operator= (TcpClientImpl &&other) noexcept=delete | 
| ~TcpClientImpl () noexcept=default | |
| Destruct an instance of TcpClientImpl.  More... | |
| void | Initialize () noexcept | 
| Initialize the client.  More... | |
| void | DeInitialize () noexcept | 
| De-initialize the client.  More... | |
| void | SetReadHandler (HandlerRead read_handler) noexcept | 
| Function to set the read handler that is invoked when message is received.  More... | |
| core_type::Result< void > | ConnectToHost (std::string_view host_ip_address, std::uint16_t host_port_num) | 
| Function to connect to remote ip address and port number.  More... | |
| core_type::Result< void > | DisconnectFromHost () | 
| Function to disconnect from remote host if already connected.  More... | |
| auto | IsConnectedToHost () const noexcept -> bool | 
| Function to get the connection status.  More... | |
| core_type::Result< void > | Transmit (MessageConstPtr tcp_message) | 
| Function to transmit the provided tcp message.  More... | |
Private Types | |
| enum class | State : std::uint8_t { kConnected = 0U , kDisconnected = 1U } | 
| Definitions of different connection state.  More... | |
| using | TcpConnection = connection::tcp::TcpConnection< connection::tcp::ConnectionType::kClient, socket::tcp::TcpSocket > | 
| Type alias for unsecured tcp connection.  More... | |
| using | IoContext = boost_support::socket::IoContext | 
| Type alias for boost context.  More... | |
Private Attributes | |
| IoContext | io_context_ | 
| Stores the io context.  More... | |
| std::atomic< State > | connection_state_ | 
| Store the state of tcp connection.  More... | |
| std::string | client_name_ | 
| The client name.  More... | |
| TcpConnection | tcp_connection_ | 
| Store the tcp connection.  More... | |
Class to provide implementation of tcp client.
Definition at line 42 of file tcp_client.cpp.
      
  | 
  private | 
Type alias for boost context.
Definition at line 61 of file tcp_client.cpp.
      
  | 
  private | 
Type alias for unsecured tcp connection.
Definition at line 47 of file tcp_client.cpp.
      
  | 
  strongprivate | 
Definitions of different connection state.
| Enumerator | |
|---|---|
| kConnected | Connected to remote server  | 
| kDisconnected | Disconnected from remote server  | 
Definition at line 53 of file tcp_client.cpp.
      
  | 
  inlinenoexcept | 
Constructs an instance of TcpClientImpl.
| [in] | local_ip_address | The local ip address of client | 
| [in] | local_port_num | The local port number of client | 
Definition at line 71 of file tcp_client.cpp.
      
  | 
  deletenoexcept | 
Deleted copy assignment and copy constructor.
      
  | 
  deletenoexcept | 
Deleted move assignment and move constructor.
      
  | 
  defaultnoexcept | 
Destruct an instance of TcpClientImpl.
      
  | 
  inline | 
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 124 of file tcp_client.cpp.
References connection_state_, FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), kConnected, boost_support::error_domain::kSocketError, boost_support::error_domain::MakeErrorCode(), and tcp_connection_.

      
  | 
  inlinenoexcept | 
De-initialize the client.
Definition at line 104 of file tcp_client.cpp.
References tcp_connection_.
      
  | 
  inline | 
Function to disconnect from remote host if already connected.
Definition at line 147 of file tcp_client.cpp.
References connection_state_, FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), kConnected, kDisconnected, boost_support::error_domain::kSocketError, boost_support::error_domain::MakeErrorCode(), and tcp_connection_.

      
  | 
  inlinenoexcept | 
      
  | 
  inlinenoexcept | 
Function to get the connection status.
Definition at line 167 of file tcp_client.cpp.
References connection_state_, and kConnected.
      
  | 
  deletenoexcept | 
      
  | 
  deletenoexcept | 
      
  | 
  inlinenoexcept | 
Function to set the read handler that is invoked when message is received.
The ownership of provided read handler is moved
| [in] | read_handler | The handler to be set | 
Definition at line 112 of file tcp_client.cpp.
References tcp_connection_.
      
  | 
  inline | 
Function to transmit the provided tcp message.
| [in] | tcp_message | The tcp message | 
Definition at line 177 of file tcp_client.cpp.
References connection_state_, FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), kConnected, boost_support::error_domain::kGenericError, boost_support::error_domain::MakeErrorCode(), and tcp_connection_.

      
  | 
  private | 
The client name.
Definition at line 206 of file tcp_client.cpp.
      
  | 
  private | 
Store the state of tcp connection.
Definition at line 201 of file tcp_client.cpp.
Referenced by ConnectToHost(), DisconnectFromHost(), IsConnectedToHost(), and Transmit().
      
  | 
  private | 
Stores the io context.
Definition at line 196 of file tcp_client.cpp.
      
  | 
  private | 
Store the tcp connection.
Definition at line 211 of file tcp_client.cpp.
Referenced by ConnectToHost(), DeInitialize(), DisconnectFromHost(), Initialize(), SetReadHandler(), and Transmit().