From 24230515f5b1652186af7748268f1cfb27f5215f Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 4 Aug 2011 13:11:15 +0200 Subject: vtcp connection string simplified Till now, vtcp connection contained both port and subport. Now the port, if not specified, defaults to 9220. Signed-off-by: Martin Sustrik --- src/vtcp_connecter.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/vtcp_connecter.cpp') diff --git a/src/vtcp_connecter.cpp b/src/vtcp_connecter.cpp index 842aa3a..5c72044 100644 --- a/src/vtcp_connecter.cpp +++ b/src/vtcp_connecter.cpp @@ -83,15 +83,27 @@ int zmq::vtcp_connecter_t::set_address (const char *addr_) { const char *delimiter = strrchr (addr_, '.'); if (!delimiter) { - errno = EINVAL; - return -1; + delimiter = strrchr (addr_, ':'); + if (!delimiter) { + errno = EINVAL; + return -1; + } + std::string addr_str (addr_, delimiter - addr_); + addr_str += ":9220"; + std::string subport_str (delimiter + 1); + subport = (vtcp_subport_t) atoi (subport_str.c_str ()); + int rc = resolve_ip_hostname (&addr, &addr_len, addr_str.c_str ()); + if (rc != 0) + return -1; + } + else { + std::string addr_str (addr_, delimiter - addr_); + std::string subport_str (delimiter + 1); + subport = (vtcp_subport_t) atoi (subport_str.c_str ()); + int rc = resolve_ip_hostname (&addr, &addr_len, addr_str.c_str ()); + if (rc != 0) + return -1; } - std::string addr_str (addr_, delimiter - addr_); - std::string subport_str (delimiter + 1); - subport = (vtcp_subport_t) atoi (subport_str.c_str ()); - int rc = resolve_ip_hostname (&addr, &addr_len, addr_str.c_str ()); - if (rc != 0) - return -1; return 0; } -- cgit v1.2.3