diff options
author | Martin Lucina <martin@lucina.net> | 2012-05-20 07:40:11 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-05-25 14:02:16 +0200 |
commit | a34ea4d80609395150742259fd8c9caa4409e961 (patch) | |
tree | aa5c1793e7e5e276e4ded626adbe042e75740ff6 /src/sub.cpp | |
parent | 6b7089891bdb3a4c55b43d0854787c96fae3bf2b (diff) |
Implement SP wire protocol
Implements the SP wire protocol, and infrastructure for legacy wire
protocol support.
Also added an XS_SERVICE_ID socket option to set the service id and renamed
the XS_PROTOCOL option to XS_PATTERN_VERSION.
The following pattern versions are supported:
PAIR: v3
PUBSUB: v1 (legacy), v4
REQREP: v2
PIPELINE: v3
SURVEY: v2
Note that all existing pattern versions have been bumped by 1 to allow for
use of legacy protocols (otherwise there would be no way to distinguish
between e.g. PUBSUB v3 and PUBSUB v3 using SP).
Signed-off-by: Martin Lucina <martin@lucina.net>
Diffstat (limited to 'src/sub.cpp')
-rw-r--r-- | src/sub.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/sub.cpp b/src/sub.cpp index d29ae8d..79cb63c 100644 --- a/src/sub.cpp +++ b/src/sub.cpp @@ -48,8 +48,7 @@ int xs::sub_t::xsetsockopt (int option_, const void *optval_, size_t optvallen_) { if (option_ != XS_SUBSCRIBE && option_ != XS_UNSUBSCRIBE) { - errno = EINVAL; - return -1; + return xsub_t::xsetsockopt (option_, optval_, optvallen_); } if (optvallen_ > 0 && !optval_) { @@ -202,7 +201,7 @@ int xs::sub_t::filter_subscribed (const unsigned char *data_, size_t size_) int rc = msg.init_size (size_ + 4); errno_assert (rc == 0); unsigned char *data = (unsigned char*) msg.data (); - put_uint16 (data, XS_CMD_SUBSCRIBE); + put_uint16 (data, SP_PUBSUB_CMD_SUBSCRIBE); put_uint16 (data + 2, options.filter); memcpy (data + 4, data_, size_); @@ -225,7 +224,7 @@ int xs::sub_t::filter_unsubscribed (const unsigned char *data_, size_t size_) int rc = msg.init_size (size_ + 4); errno_assert (rc == 0); unsigned char *data = (unsigned char*) msg.data (); - put_uint16 (data, XS_CMD_UNSUBSCRIBE); + put_uint16 (data, SP_PUBSUB_CMD_UNSUBSCRIBE); put_uint16 (data + 2, options.filter); memcpy (data + 4, data_, size_); |