summaryrefslogtreecommitdiff
path: root/src/socket_base.cpp
diff options
context:
space:
mode:
authorDouglas Young <rcxdude@gmail.com>2012-05-05 19:03:31 +0100
committerMartin Sustrik <sustrik@250bpm.com>2012-05-06 02:22:30 +0200
commitc618421d6f74c0d8838c1d322304eed8321af27d (patch)
treec882fe8e733cc61aa98654154402d70223d0bd4e /src/socket_base.cpp
parent4e6a1e5508151d308a53124e4733ae1c1f7b3fb2 (diff)
Return error if an invalid connection string is used
This patch reintroduces the behaviour that if a tcp:// or ipc:// connection string which is invalid is passed to xs_connect, then an error is reported, instead of asserting at connection time
Diffstat (limited to 'src/socket_base.cpp')
-rw-r--r--src/socket_base.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index ec5c8bd..8ee8bd3 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -39,6 +39,7 @@
#include "tcp_listener.hpp"
#include "ipc_listener.hpp"
#include "tcp_connecter.hpp"
+#include "ipc_connecter.hpp"
#include "io_thread.hpp"
#include "session_base.hpp"
#include "config.hpp"
@@ -491,6 +492,22 @@ int xs::socket_base_t::connect (const char *addr_)
io_thread_t *thread = choose_io_thread (options.affinity);
xs_assert (thread);
+ if (protocol == "tcp") {
+ tcp_connecter_t connecter (thread, NULL, options, false);
+ int rc = connecter.set_address (address.c_str());
+ if (rc != 0) {
+ return -1;
+ }
+ }
+
+ if (protocol == "ipc") {
+ ipc_connecter_t connecter (thread, NULL, options, false);
+ int rc = connecter.set_address (address.c_str());
+ if (rc != 0) {
+ return -1;
+ }
+ }
+
// Create session.
session_base_t *session = session_base_t::create (thread, true, this,
options, protocol.c_str (), address.c_str ());