mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 18:40:27 +01:00
Problem: wildcard port binding does not work with WS sockets
Solution: remove the path from the address when resolving
This commit is contained in:
parent
79d75f017c
commit
c711941e9a
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user