diff --git a/src/cpp/rtps/transport/TCPTransportInterface.cpp b/src/cpp/rtps/transport/TCPTransportInterface.cpp index 0c4da1a9d9a..109bc3b53a8 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.cpp +++ b/src/cpp/rtps/transport/TCPTransportInterface.cpp @@ -299,7 +299,7 @@ void TCPTransportInterface::calculate_crc( } uint16_t TCPTransportInterface::create_acceptor_socket( - const Locator& locator) + Locator& locator) { uint16_t final_port = 0; try @@ -338,6 +338,14 @@ uint16_t TCPTransportInterface::create_acceptor_socket( #if TLS_FOUND if (configuration()->apply_security) { + if (locator.kind == LOCATOR_KIND_TCPv4) + { + IPLocator::setIPv4(locator, sInterface); + } + else if (locator.kind == LOCATOR_KIND_TCPv6) + { + IPLocator::setIPv6(locator, sInterface); + } std::shared_ptr acceptor = std::make_shared(io_service_, sInterface, locator); acceptors_[acceptor->locator()] = acceptor; @@ -347,6 +355,14 @@ uint16_t TCPTransportInterface::create_acceptor_socket( else #endif // if TLS_FOUND { + if (locator.kind == LOCATOR_KIND_TCPv4) + { + IPLocator::setIPv4(locator, sInterface); + } + else if (locator.kind == LOCATOR_KIND_TCPv6) + { + IPLocator::setIPv6(locator, sInterface); + } std::shared_ptr acceptor = std::make_shared(io_service_, sInterface, locator); acceptors_[acceptor->locator()] = acceptor; diff --git a/src/cpp/rtps/transport/TCPTransportInterface.h b/src/cpp/rtps/transport/TCPTransportInterface.h index 778a13f2a58..4be865dc959 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.h +++ b/src/cpp/rtps/transport/TCPTransportInterface.h @@ -143,7 +143,7 @@ class TCPTransportInterface : public TransportInterface //! Creates a TCP acceptor to wait for incoming connections by the given locator. uint16_t create_acceptor_socket( - const Locator& locator); + Locator& locator); virtual void get_ips( std::vector& loc_names,