summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGonzalo Diethelm <gdiethelm@dcv.cl>2010-09-28 15:27:45 +0200
committerMartin Sustrik <sustrik@250bpm.com>2010-09-28 15:27:45 +0200
commit87beaaa00d49d216f856b8322f1ad04e4f9ecea3 (patch)
treef6feb3fd05c3691d7315636464fcf4c9a4f1afcc /src
parent6715f9b1858587db6aec826bdc9a7905bba8030e (diff)
ZMQ_TYPE socket option added
Diffstat (limited to 'src')
-rw-r--r--src/options.cpp10
-rw-r--r--src/options.hpp3
-rw-r--r--src/pair.cpp1
-rw-r--r--src/pub.cpp1
-rw-r--r--src/pull.cpp1
-rw-r--r--src/push.cpp1
-rw-r--r--src/rep.cpp1
-rw-r--r--src/req.cpp1
-rw-r--r--src/sub.cpp1
-rw-r--r--src/xrep.cpp1
-rw-r--r--src/xreq.cpp1
11 files changed, 22 insertions, 0 deletions
diff --git a/src/options.cpp b/src/options.cpp
index dcbb51d..e644a9b 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -33,6 +33,7 @@ zmq::options_t::options_t () :
use_multicast_loop (true),
sndbuf (0),
rcvbuf (0),
+ type (-1),
requires_in (false),
requires_out (false),
immediate_connect (true)
@@ -137,6 +138,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
{
switch (option_) {
+ case ZMQ_TYPE:
+ if (*optvallen_ < sizeof (int)) {
+ errno = EINVAL;
+ return -1;
+ }
+ *((int*) optval_) = type;
+ *optvallen_ = sizeof (int);
+ return 0;
+
case ZMQ_HWM:
if (*optvallen_ < sizeof (uint64_t)) {
errno = EINVAL;
diff --git a/src/options.hpp b/src/options.hpp
index 908b166..ea0c841 100644
--- a/src/options.hpp
+++ b/src/options.hpp
@@ -51,6 +51,9 @@ namespace zmq
uint64_t sndbuf;
uint64_t rcvbuf;
+ // Socket type.
+ int type;
+
// These options are never set by the user directly. Instead they are
// provided by the specific socket type.
bool requires_in;
diff --git a/src/pair.cpp b/src/pair.cpp
index faea167..f5df59f 100644
--- a/src/pair.cpp
+++ b/src/pair.cpp
@@ -31,6 +31,7 @@ zmq::pair_t::pair_t (class ctx_t *parent_, uint32_t slot_) :
outpipe_alive (false),
terminating (false)
{
+ options.type = ZMQ_PAIR;
options.requires_in = true;
options.requires_out = true;
}
diff --git a/src/pub.cpp b/src/pub.cpp
index 6edd991..b1a1239 100644
--- a/src/pub.cpp
+++ b/src/pub.cpp
@@ -29,6 +29,7 @@ zmq::pub_t::pub_t (class ctx_t *parent_, uint32_t slot_) :
active (0),
terminating (false)
{
+ options.type = ZMQ_PUB;
options.requires_in = false;
options.requires_out = true;
}
diff --git a/src/pull.cpp b/src/pull.cpp
index cbfcdbf..c5f6a8e 100644
--- a/src/pull.cpp
+++ b/src/pull.cpp
@@ -26,6 +26,7 @@ zmq::pull_t::pull_t (class ctx_t *parent_, uint32_t slot_) :
socket_base_t (parent_, slot_),
fq (this)
{
+ options.type = ZMQ_PULL;
options.requires_in = true;
options.requires_out = false;
}
diff --git a/src/push.cpp b/src/push.cpp
index 20943fc..f48f7bb 100644
--- a/src/push.cpp
+++ b/src/push.cpp
@@ -27,6 +27,7 @@ zmq::push_t::push_t (class ctx_t *parent_, uint32_t slot_) :
socket_base_t (parent_, slot_),
lb (this)
{
+ options.type = ZMQ_PUSH;
options.requires_in = false;
options.requires_out = true;
}
diff --git a/src/rep.cpp b/src/rep.cpp
index b2ada66..2904f06 100644
--- a/src/rep.cpp
+++ b/src/rep.cpp
@@ -27,6 +27,7 @@ zmq::rep_t::rep_t (class ctx_t *parent_, uint32_t slot_) :
sending_reply (false),
request_begins (true)
{
+ options.type = ZMQ_REP;
}
zmq::rep_t::~rep_t ()
diff --git a/src/req.cpp b/src/req.cpp
index 8a5126d..03203c5 100644
--- a/src/req.cpp
+++ b/src/req.cpp
@@ -27,6 +27,7 @@ zmq::req_t::req_t (class ctx_t *parent_, uint32_t slot_) :
receiving_reply (false),
message_begins (true)
{
+ options.type = ZMQ_REQ;
}
zmq::req_t::~req_t ()
diff --git a/src/sub.cpp b/src/sub.cpp
index bee8a06..825b350 100644
--- a/src/sub.cpp
+++ b/src/sub.cpp
@@ -30,6 +30,7 @@ zmq::sub_t::sub_t (class ctx_t *parent_, uint32_t slot_) :
has_message (false),
more (false)
{
+ options.type = ZMQ_SUB;
options.requires_in = true;
options.requires_out = false;
zmq_msg_init (&message);
diff --git a/src/xrep.cpp b/src/xrep.cpp
index c1cfb00..b8ad735 100644
--- a/src/xrep.cpp
+++ b/src/xrep.cpp
@@ -32,6 +32,7 @@ zmq::xrep_t::xrep_t (class ctx_t *parent_, uint32_t slot_) :
more_out (false),
terminating (false)
{
+ options.type = ZMQ_XREP;
options.requires_in = true;
options.requires_out = true;
diff --git a/src/xreq.cpp b/src/xreq.cpp
index 2373f34..9f4eb92 100644
--- a/src/xreq.cpp
+++ b/src/xreq.cpp
@@ -27,6 +27,7 @@ zmq::xreq_t::xreq_t (class ctx_t *parent_, uint32_t slot_) :
fq (this),
lb (this)
{
+ options.type = ZMQ_XREQ;
options.requires_in = true;
options.requires_out = true;
}