Adding ZMQ_LAST_ENDPOINT for wildcard support on TCP and IPC sockets

This commit is contained in:
Ian Barber
2012-02-08 22:06:46 +00:00
parent 7e8a839a22
commit 7b32c9cb51
9 changed files with 99 additions and 7 deletions

View File

@@ -387,11 +387,17 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv4only_)
addr_str [addr_str.size () - 1] == ']')
addr_str = addr_str.substr (1, addr_str.size () - 2);
// Parse the port number (0 is not a valid port).
uint16_t port = (uint16_t) atoi (port_str.c_str());
if (port == 0) {
errno = EINVAL;
return -1;
uint16_t port;
if (port_str[0] == '*') {
// Resolve wildcard to 0 to allow autoselection of port
port = 0;
} else {
// Parse the port number (0 is not a valid port).
port = (uint16_t) atoi (port_str.c_str());
if (port == 0) {
errno = EINVAL;
return -1;
}
}
// Resolve the IP address.