File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
ecal/core/src/readwrite/tcp Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 3232#include " ecal_utils/portable_endian.h"
3333
3434#include < cstring>
35+ #include < asio.hpp>
36+
37+ namespace {
38+ constexpr int ANY_PORT = 0 ;
39+
40+ bool IsIpv6Supported ()
41+ {
42+ asio::error_code ec;
43+ asio::ip::tcp::socket sock (asio::system_executor{});
44+ std::ignore = sock.open (asio::ip::tcp::v6 (), ec);
45+ return !ec;
46+ }
47+
48+ std::string& GetPreferredAnyAddress () {
49+ static std::string any_address = IsIpv6Supported () ?
50+ " ::" : " 0.0.0.0" ;
51+ return any_address;
52+ }
53+ }
3554
3655namespace eCAL
3756{
@@ -50,7 +69,7 @@ namespace eCAL
5069 }
5170
5271 // create publisher
53- m_publisher = std::make_shared<tcp_pubsub::Publisher>(g_tcp_writer_executor);
72+ m_publisher = std::make_shared<tcp_pubsub::Publisher>(g_tcp_writer_executor, GetPreferredAnyAddress (), ANY_PORT );
5473 m_port = m_publisher->getPort ();
5574 }
5675
You can’t perform that action at this time.
0 commit comments