11 #include <boost/asio/ip/address.hpp> 
   21                      boost::asio::io_context &io_context) noexcept
 
   22     : udp_socket_{io_context},
 
   23       local_endpoint_{boost::asio::ip::make_address(local_ip_address), local_port_num} {
 
   30   udp_handler_read_ = std::move(read_handler);
 
   37   if (ec.value() == boost::system::errc::success) {
 
   39     udp_socket_.set_option(boost::asio::socket_base::broadcast{
true});
 
   41     udp_socket_.set_option(boost::asio::socket_base::reuse_address{
true});
 
   44   if (ec.value() == boost::system::errc::success) {
 
   47         FILE_NAME, __LINE__, __func__, [
this](std::stringstream &msg) {
 
   48           msg << 
"Udp Socket opened and bound to " 
   53     result.EmplaceValue();
 
   58         FILE_NAME, __LINE__, __func__, [ec](std::stringstream &msg) {
 
   59           msg << 
"Udp Socket Bind failed with message: " << ec.message();
 
   71   std::size_t 
const send_size{udp_socket_.send_to(
 
   72       boost::asio::buffer(udp_message->GetPayload().data(), udp_message->GetPayload().size()),
 
   73       Udp::endpoint{boost::asio::ip::make_address(udp_message->GetHostIpAddress()),
 
   74                     udp_message->GetHostPortNumber()},
 
   77   if (ec.value() == boost::system::errc::success && send_size == udp_message->GetPayload().size()) {
 
   80         FILE_NAME, __LINE__, __func__, [
this, &udp_message](std::stringstream &msg) {
 
   81           msg << 
"Udp message sent : " 
   82               << 
"<" << local_endpoint_.address() << 
"," << local_endpoint_.port() << 
">" 
   84               << 
"<" << udp_message->GetHostIpAddress() << 
"," << udp_message->GetHostPortNumber()
 
   87     result.EmplaceValue();
 
   89     StartReceivingMessage();
 
   92         FILE_NAME, __LINE__, __func__, [&ec, &udp_message](std::stringstream &msg) {
 
   93           msg << 
"Udp message sending to " 
   94               << 
"<" << udp_message->GetHostIpAddress() << 
"> " 
   95               << 
"failed with error: " << ec.message();
 
  105   result.EmplaceValue();
 
  115     received_data.reserve(total_bytes_received);
 
  120     received_data.insert(received_data.begin(), 
rx_buffer_.begin(),
 
  121                          rx_buffer_.begin() + 
static_cast<std::uint8_t
>(total_bytes_received));
 
  127         FILE_NAME, __LINE__, __func__, [
this](std::stringstream &msg) {
 
  128           msg << 
"Udp Message received from: " 
  131     result.EmplaceValue(std::move(udp_rx_message));
 
  134         FILE_NAME, __LINE__, __func__, [
this](std::stringstream &msg) {
 
  135           msg << 
"Udp Message received from " 
  137               << 
" ignored as received by self ip" 
  151         if (error.value() == boost::system::errc::success) {
 
  152           static_cast<void>(Read(bytes_received).AndThen([this](UdpMessagePtr udp_message) {
 
  154             if (udp_handler_read_) { udp_handler_read_(std::move(udp_message)); }
 
  155             return core_type::Result<void>::FromValue();
 
  158           if (error.value() != boost::asio::error::operation_aborted) {
 
  160                 FILE_NAME, __LINE__, __func__, [error](std::stringstream &msg) {
 
  161                   msg << 
"Remote Disconnected with undefined error: " << error.message();
 
static auto GetLibBoostLogger() noexcept -> LibBoostLogger &
 
std::vector< uint8_t > BufferType
Type alias for underlying buffer.
 
Class used to create a udp socket for handling transmission and reception of udp message from driver.
 
boost_support::message::udp::UdpMessageConstPtr UdpMessageConstPtr
Type alias for Udp message const pointer.
 
void StartReceivingMessage()
Function to start reception of Udp dataframe.
 
core_type::Result< void, SocketError > Close() noexcept
Function to destroy the socket.
 
std::vector< std::uint8_t > rx_buffer_
Reception buffer needed for async reception of udp data.
 
~UdpSocket() noexcept
Destruct an instance of TcpSocket.
 
Udp::endpoint local_endpoint_
Store the local endpoints.
 
std::function< void(UdpMessagePtr)> UdpHandlerRead
Udp function template used for reception.
 
core_type::Result< UdpMessagePtr > Read(std::size_t bytes_received)
Function to handle the reception of tcp message.
 
boost::system::error_code UdpErrorCodeType
Type alias for udp error codes.
 
core_type::Result< void, SocketError > Transmit(UdpMessageConstPtr udp_message) noexcept
Function to trigger transmission.
 
Socket udp_socket_
Store the underlying udp socket.
 
UdpSocket(std::string_view local_ip_address, std::uint16_t local_port_num, boost::asio::io_context &io_context) noexcept
Constructs an instance of TcpSocket.
 
core_type::Result< void, SocketError > Open() noexcept
Function to open and bind the socket to provided ip address & port.
 
boost_support::message::udp::UdpMessagePtr UdpMessagePtr
Type alias for Udp message pointer.
 
Udp::endpoint remote_endpoint_
Store the remote endpoints.
 
Class type to contains a value (of type ValueType), or an error (of type ErrorType)
 
auto MakeErrorCode(BoostSupportErrorDomain::Errc code, BoostSupportErrorDomain::SupportDataType data) noexcept -> core_type::ErrorCode
Create a new ErrorCode within DoipErrorDomain.
 
constexpr std::uint8_t kMaxUdpResSize
Maximum response size.