Commit c711941e authored by Luca Boccassi's avatar Luca Boccassi

Problem: wildcard port binding does not work with WS sockets

Solution: remove the path from the address when resolving
parent 79d75f01
...@@ -105,6 +105,8 @@ int zmq::ws_address_t::resolve (const char *name_, bool local_, bool ipv6_) ...@@ -105,6 +105,8 @@ int zmq::ws_address_t::resolve (const char *name_, bool local_, bool ipv6_)
_path = std::string (delim); _path = std::string (delim);
else else
_path = std::string ("/"); _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; ip_resolver_options_t resolver_opts;
resolver_opts.bindable (local_) resolver_opts.bindable (local_)
...@@ -116,7 +118,7 @@ int zmq::ws_address_t::resolve (const char *name_, bool local_, bool ipv6_) ...@@ -116,7 +118,7 @@ int zmq::ws_address_t::resolve (const char *name_, bool local_, bool ipv6_)
ip_resolver_t resolver (resolver_opts); 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 int zmq::ws_address_t::to_string (std::string &addr_) const
......
...@@ -206,7 +206,10 @@ int zmq::ws_listener_t::set_local_address (const char *addr_) ...@@ -206,7 +206,10 @@ int zmq::ws_listener_t::set_local_address (const char *addr_)
if (rc != 0) if (rc != 0)
return -1; 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; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment