diff options
Diffstat (limited to 'implementation/endpoints/src/udp_server_endpoint_impl.cpp')
-rw-r--r-- | implementation/endpoints/src/udp_server_endpoint_impl.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index 9d22d51..ce1bb2d 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -303,12 +303,26 @@ void udp_server_endpoint_impl::join(const std::string &_address) { boost::system::error_code ec; + bool is_v4(false); + bool is_v6(false); + { + std::lock_guard<std::mutex> its_lock(local_mutex_); + is_v4 = local_.address().is_v4(); + is_v6 = local_.address().is_v6(); + } + if (multicast_recv_buffer_.empty()) multicast_recv_buffer_.resize(VSOMEIP_MAX_UDP_MESSAGE_SIZE, 0); if (!multicast_local_) { - multicast_local_ = std::unique_ptr<endpoint_type>( - new endpoint_type(boost::asio::ip::address_v4::any(), local_port_)); + if (is_v4) { + multicast_local_ = std::unique_ptr<endpoint_type>( + new endpoint_type(boost::asio::ip::address_v4::any(), local_port_)); + } + if (is_v6) { + multicast_local_ = std::unique_ptr<endpoint_type>( + new endpoint_type(boost::asio::ip::address_v6::any(), local_port_)); + } } if (!multicast_socket_) { @@ -360,14 +374,6 @@ void udp_server_endpoint_impl::join(const std::string &_address) { receive_multicast(multicast_id_); } - bool is_v4(false); - bool is_v6(false); - { - std::lock_guard<std::mutex> its_lock(local_mutex_); - is_v4 = local_.address().is_v4(); - is_v6 = local_.address().is_v6(); - } - if (is_v4) { multicast_socket_->set_option(ip::udp_ext::socket::reuse_address(true)); multicast_socket_->set_option( |