8 #ifndef DIAG_CLIENT_LIB_LIB_BOOST_SUPPORT_SOCKET_TCP_TCP_SOCKET_H_
9 #define DIAG_CLIENT_LIB_LIB_BOOST_SUPPORT_SOCKET_TCP_TCP_SOCKET_H_
11 #include <boost/asio.hpp>
54 using Tcp = boost::asio::ip::tcp;
71 TcpSocket(std::string_view local_ip_address, std::uint16_t local_port_num,
113 std::uint16_t host_port_num) noexcept;
Immutable class to store received tcp message.
Wrapper class to hold boost io context required for io object( sockets)
Class used to create a tcp socket for handling transmission and reception of tcp message from driver.
TcpSocket(std::string_view local_ip_address, std::uint16_t local_port_num, IoContext &io_context) noexcept
Constructs an instance of TcpSocket.
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.
boost_support::message::tcp::TcpMessagePtr TcpMessagePtr
Type alias for Tcp message pointer.
SocketError
Socket error code.
core_type::Result< void, SocketError > Close() noexcept
Function to destroy the socket.
TcpSocket & operator=(TcpSocket &&other) noexcept=default
core_type::Result< TcpMessagePtr, SocketError > Read() noexcept
Function to read message from socket.
TcpSocket(TcpSocket &&other) noexcept=default
Move assignment and Move constructor.
core_type::Result< void, SocketError > Disconnect() noexcept
Function to Disconnect from host.
boost_support::message::tcp::TcpMessageConstPtr TcpMessageConstPtr
Type alias for Tcp message const pointer.
Tcp::socket Socket
Type alias for tcp socket.
boost::asio::ip::tcp Tcp
Type alias for tcp protocol.
core_type::Result< void, SocketError > Transmit(TcpMessageConstPtr tcp_message) noexcept
Function to trigger transmission.
TcpSocket(const TcpSocket &other) noexcept=delete
Deleted copy assignment and copy constructor.
~TcpSocket() noexcept
Destruct an instance of TcpSocket.
boost::asio::ip::address TcpIpAddress
Type alias for tcp ip address.
TcpSocket & operator=(const TcpSocket &other) noexcept=delete
Socket tcp_socket_
Store the underlying tcp socket.
Tcp::endpoint local_endpoint_
Store the local endpoints.
boost::system::error_code TcpErrorCodeType
Type alias for tcp error codes.
core_type::Result< void, SocketError > Open() noexcept
Function to open and bind the socket to provided ip address & port.
std::unique_ptr< TcpMessage > TcpMessagePtr
The unique pointer to TcpMessage.
std::unique_ptr< TcpMessage const > TcpMessageConstPtr
The unique pointer to const TcpMessage.
core_type::Result< T, E > Result
Class type to contains a value (of type ValueType), or an error (of type ErrorType)