8 #ifndef DIAG_CLIENT_LIB_LIB_BOOST_SUPPORT_SOCKET_UDP_UDP_CLIENT_H_
9 #define DIAG_CLIENT_LIB_LIB_BOOST_SUPPORT_SOCKET_UDP_UDP_CLIENT_H_
11 #include <boost/asio.hpp>
13 #include <string_view>
88 using Udp = boost::asio::ip::udp;
Class used to create a udp socket for handling transmission and reception of udp message from driver.
std::atomic_bool running_
Flag to start the thread.
std::atomic_bool exit_request_
Flag to terminate the thread.
virtual ~UdpClientSocket()
Destruct an instance of UdpClientSocket.
void HandleMessage(const UdpErrorCodeType &error, std::size_t bytes_received)
Function to handle the reception of tcp message.
Udp::endpoint remote_endpoint_
Store the remote endpoint.
std::function< void(UdpMessagePtr)> UdpHandlerRead
Udp function template used for reception.
core_type::Result< void, UdpErrorCode > Destroy()
Function to destroy the socket.
PortType port_type_
Store the port type - broadcast / unicast.
PortType
Type of udp port to be used underneath.
std::string local_ip_address_
Store local ip address.
boost::asio::ip::address UdpIpAddress
Type alias for udp ip address.
std::condition_variable cond_var_
Conditional variable to block the thread.
boost::system::error_code UdpErrorCodeType
Type alias for udp error codes.
boost::asio::ip::udp Udp
Type alias for udp protocol.
UdpSocket udp_socket_
Store tcp socket.
core_type::Result< void, UdpErrorCode > Transmit(UdpMessageConstPtr udp_message)
Function to trigger transmission.
std::thread thread_
The thread itself.
std::uint16_t local_port_num_
Store local port number.
boost::asio::io_context io_context_
boost io context
UdpErrorCode
Udp error code.
std::array< std::uint8_t, kDoipUdpResSize > rx_buffer_
Reception buffer needed for async reception of udp data.
std::mutex mutex_
mutex to lock critical section
core_type::Result< void, UdpErrorCode > Open()
Function to Open the socket.
Udp::socket UdpSocket
Type alias for udp socket.
UdpClientSocket(std::string_view local_ip_address, std::uint16_t local_port_num, PortType port_type, UdpHandlerRead udp_handler_read)
Constructs an instance of UdpClientSocket.
UdpHandlerRead udp_handler_read_
Store the handler.
Class type to contains a value (of type ValueType), or an error (of type ErrorType)
std::unique_ptr< const UdpMessage > UdpMessageConstPtr
The unique pointer to const UdpMessage.
std::unique_ptr< UdpMessage > UdpMessagePtr
The unique pointer to UdpMessage.