diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2011-07-26 22:57:19 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2011-07-26 22:57:19 +0200 |
commit | d7319de3d089b7c340408cd8228825ec0f7b8df0 (patch) | |
tree | 0741c9f0dbde0119da8905b5299a8460869037f0 /src/vtcp_listener.cpp | |
parent | 258e7e6794928544ca7e1557840b2f5a89fe5399 (diff) |
First version of vtcp_connecter added
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/vtcp_listener.cpp')
-rw-r--r-- | src/vtcp_listener.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/vtcp_listener.cpp b/src/vtcp_listener.cpp index 31fb9ac..60fad8c 100644 --- a/src/vtcp_listener.cpp +++ b/src/vtcp_listener.cpp @@ -50,15 +50,20 @@ zmq::vtcp_listener_t::~vtcp_listener_t () int zmq::vtcp_listener_t::set_address (const char *addr_) { - // Find the '.' at end that separates NIC name from service. + // VTCP doesn't allow for binding to a specific interface. Connection + // string has to begin with *: (INADDR_ANY). + if (strlen (addr_) < 2 || addr_ [0] != '*' || addr_ [1] != ':') { + errno = EADDRNOTAVAIL; + return -1; + } + + // Parse port and subport. const char *delimiter = strrchr (addr_, '.'); if (!delimiter) { errno = EINVAL; return -1; } - - // Parse port and subport. - std::string port_str (addr_, delimiter - addr_); + 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 ()); |