summaryrefslogtreecommitdiff
path: root/src/socket_base.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-07-26 18:35:40 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-07-26 18:35:40 +0200
commit279302c5f54ddf8a23b1eaacee63c3158850d9ff (patch)
tree501200a6a2189fb9ed0a158cb825c653343729d9 /src/socket_base.cpp
parent9906c652ca01698dcc429c9045eb040c24c4bb8d (diff)
Experimental VTCP listener added
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/socket_base.cpp')
-rw-r--r--src/socket_base.cpp53
1 files changed, 38 insertions, 15 deletions
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index b97e3a7..fb0f5fd 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -35,6 +35,7 @@
#include "socket_base.hpp"
#include "tcp_listener.hpp"
+#include "vtcp_listener.hpp"
#include "tcp_connecter.hpp"
#include "io_thread.hpp"
#include "session.hpp"
@@ -174,7 +175,8 @@ int zmq::socket_base_t::check_protocol (const std::string &protocol_)
{
// First check out whether the protcol is something we are aware of.
if (protocol_ != "inproc" && protocol_ != "ipc" && protocol_ != "tcp" &&
- protocol_ != "pgm" && protocol_ != "epgm" && protocol_ != "sys") {
+ protocol_ != "pgm" && protocol_ != "epgm" && protocol_ != "sys" &&
+ protocol_ != "vtcp") {
errno = EPROTONOSUPPORT;
return -1;
}
@@ -188,6 +190,14 @@ int zmq::socket_base_t::check_protocol (const std::string &protocol_)
}
#endif
+ // If 0MQ is not compiled with VTCP, vtcp transport is not avaialble.
+#if !defined ZMQ_HAVE_VTCP
+ if (protocol_ == "vtcp") {
+ errno = EPROTONOSUPPORT;
+ return -1;
+ }
+#endif
+
// IPC transport is not available on Windows and OpenVMS.
#if defined ZMQ_HAVE_WINDOWS || defined ZMQ_HAVE_OPENVMS
if (protocol_ == "ipc") {
@@ -338,16 +348,22 @@ int zmq::socket_base_t::bind (const char *addr_)
return register_endpoint (addr_, endpoint);
}
- if (protocol == "tcp" || protocol == "ipc") {
+ if (protocol == "pgm" || protocol == "epgm") {
- // Choose I/O thread to run the listerner in.
- io_thread_t *io_thread = choose_io_thread (options.affinity);
- if (!io_thread) {
- errno = EMTHREAD;
- return -1;
- }
+ // For convenience's sake, bind can be used interchageable with
+ // connect for PGM and EPGM transports.
+ return connect (addr_);
+ }
- // Create and run the listener.
+ // Remaining trasnports require to be run in an I/O thread, so at this
+ // point we'll choose one.
+ io_thread_t *io_thread = choose_io_thread (options.affinity);
+ if (!io_thread) {
+ errno = EMTHREAD;
+ return -1;
+ }
+
+ if (protocol == "tcp" || protocol == "ipc") {
tcp_listener_t *listener = new (std::nothrow) tcp_listener_t (
io_thread, this, options);
alloc_assert (listener);
@@ -357,16 +373,23 @@ int zmq::socket_base_t::bind (const char *addr_)
return -1;
}
launch_child (listener);
-
return 0;
}
- if (protocol == "pgm" || protocol == "epgm") {
-
- // For convenience's sake, bind can be used interchageable with
- // connect for PGM and EPGM transports.
- return connect (addr_);
+#if defined ZMQ_HAVE_VTCP
+ if (protocol == "vtcp") {
+ vtcp_listener_t *listener = new (std::nothrow) vtcp_listener_t (
+ io_thread, this, options);
+ alloc_assert (listener);
+ int rc = listener->set_address (address.c_str ());
+ if (rc != 0) {
+ delete listener;
+ return -1;
+ }
+ launch_child (listener);
+ return 0;
}
+#endif
zmq_assert (false);
return -1;