diff --git a/src/ws_address.cpp b/src/ws_address.cpp index f614e122..46831fe2 100644 --- a/src/ws_address.cpp +++ b/src/ws_address.cpp @@ -105,6 +105,8 @@ int zmq::ws_address_t::resolve (const char *name_, bool local_, bool ipv6_) _path = std::string (delim); else _path = std::string ("/"); + // remove the path, otherwise resolving the port will fail with wildcard + std::string host_port = std::string (name_, delim - name_); ip_resolver_options_t resolver_opts; resolver_opts.bindable (local_) @@ -116,7 +118,7 @@ int zmq::ws_address_t::resolve (const char *name_, bool local_, bool ipv6_) ip_resolver_t resolver (resolver_opts); - return resolver.resolve (&_address, name_); + return resolver.resolve (&_address, host_port.c_str ()); } int zmq::ws_address_t::to_string (std::string &addr_) const diff --git a/src/ws_listener.cpp b/src/ws_listener.cpp index f29653d4..dc2b0e0f 100644 --- a/src/ws_listener.cpp +++ b/src/ws_listener.cpp @@ -206,7 +206,10 @@ int zmq::ws_listener_t::set_local_address (const char *addr_) if (rc != 0) return -1; - if (create_socket (addr_) == -1) + // remove the path, otherwise resolving the port will fail with wildcard + const char *delim = strrchr (addr_, '/'); + std::string host_port = std::string (addr_, delim - addr_); + if (create_socket (host_port.c_str ()) == -1) return -1; }