diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2011-08-04 13:11:15 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2011-08-04 13:11:15 +0200 |
commit | 24230515f5b1652186af7748268f1cfb27f5215f (patch) | |
tree | 9d67d8ade5c33948aa2c1f3673f33a3b1826b5eb /src/vtcp_listener.cpp | |
parent | be48970977305a53de3ffa54cc51c0beabcf1a31 (diff) |
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 <sustrik@250bpm.com>
Diffstat (limited to 'src/vtcp_listener.cpp')
-rw-r--r-- | src/vtcp_listener.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/vtcp_listener.cpp b/src/vtcp_listener.cpp index 93d9e69..685b992 100644 --- a/src/vtcp_listener.cpp +++ b/src/vtcp_listener.cpp @@ -59,15 +59,19 @@ int zmq::vtcp_listener_t::set_address (const char *addr_) } // Parse port and subport. + uint16_t port; + uint32_t subport; const char *delimiter = strrchr (addr_, '.'); if (!delimiter) { - errno = EINVAL; - return -1; + port = 9220; + subport = (uint32_t) atoi (addr_ + 2); + } + else { + std::string port_str (addr_ + 2, delimiter - addr_ - 2); + std::string subport_str (delimiter + 1); + port = (uint16_t) atoi (port_str.c_str ()); + subport = (uint32_t) atoi (subport_str.c_str ()); } - std::string port_str (addr_ + 2, delimiter - addr_ - 2); - std::string subport_str (delimiter + 1); - uint16_t port = (uint16_t) atoi (port_str.c_str ()); - uint32_t subport = (uint32_t) atoi (subport_str.c_str ()); // Start listening. s = vtcp_bind (port, subport); |