summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-09-03 10:19:08 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-09-03 10:19:08 +0200
commit193fa1c079fd886623e55810556a9461561ca139 (patch)
tree3af14d717931c9f8c7060e7f69096c16e4fcfd61 /src
parent4138aca54bd57d42acdbe7c7af0f7045ecc36e1e (diff)
Accept square brackets around IPv6 address
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r--src/tcp_address.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/tcp_address.cpp b/src/tcp_address.cpp
index b6370fa..0aa564a 100644
--- a/src/tcp_address.cpp
+++ b/src/tcp_address.cpp
@@ -373,6 +373,11 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv4only_)
std::string addr_str (name_, delimiter - name_);
std::string port_str (delimiter + 1);
+ // Remove square brackets around the address, if any.
+ if (!addr_str.empty () && addr_str [0] == '[' &&
+ 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) {