Commit 7701a8f9 authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #1487 from pijyoi/stream_notify

don't break STREAM socket ABI from 4.1.x to 4.2.0
parents 588e0d2d fd51b0e5
...@@ -716,16 +716,16 @@ Default value:: -1 (infinite) ...@@ -716,16 +716,16 @@ Default value:: -1 (infinite)
Applicable socket types:: all Applicable socket types:: all
ZMQ_STREAM_NOTIFY: send connect notifications ZMQ_STREAM_NOTIFY: send connect and disconnect notifications
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enables connect notifications on a STREAM socket, when set to 1. By default a Enables connect and disconnect notifications on a STREAM socket, when set
STREAM socket does not notify new connections. When notifications are enabled, to 1. When notifications are enabled, the socket delivers a zero-length
it delivers a zero-length message to signal new client connections. message when a peer connects or disconnects.
[horizontal] [horizontal]
Option value type:: int Option value type:: int
Option value unit:: 0, 1 Option value unit:: 0, 1
Default value:: 0 Default value:: 1
Applicable socket types:: ZMQ_STREAM Applicable socket types:: ZMQ_STREAM
......
...@@ -58,7 +58,7 @@ zmq::options_t::options_t () : ...@@ -58,7 +58,7 @@ zmq::options_t::options_t () :
invert_matching(false), invert_matching(false),
recv_identity (false), recv_identity (false),
raw_socket (false), raw_socket (false),
raw_notify (false), raw_notify (true),
tcp_keepalive (-1), tcp_keepalive (-1),
tcp_keepalive_cnt (-1), tcp_keepalive_cnt (-1),
tcp_keepalive_idle (-1), tcp_keepalive_idle (-1),
......
...@@ -965,7 +965,7 @@ int zmq::stream_engine_t::write_subscription_msg (msg_t *msg_) ...@@ -965,7 +965,7 @@ int zmq::stream_engine_t::write_subscription_msg (msg_t *msg_)
void zmq::stream_engine_t::error (error_reason_t reason) void zmq::stream_engine_t::error (error_reason_t reason)
{ {
if (options.raw_socket) { if (options.raw_socket && options.raw_notify) {
// For raw sockets, send a final 0-length message to the application // For raw sockets, send a final 0-length message to the application
// so that it knows the peer has been disconnected. // so that it knows the peer has been disconnected.
msg_t terminator; msg_t terminator;
......
...@@ -36,12 +36,15 @@ void test_stream_2_stream(){ ...@@ -36,12 +36,15 @@ void test_stream_2_stream(){
char buff[256]; char buff[256];
char msg[] = "hi 1"; char msg[] = "hi 1";
const char *bindip = "tcp://127.0.0.1:5556"; const char *bindip = "tcp://127.0.0.1:5556";
int disabled = 0;
int zero = 0; int zero = 0;
void *ctx = zmq_ctx_new (); void *ctx = zmq_ctx_new ();
// Set up listener STREAM. // Set up listener STREAM.
rbind = zmq_socket (ctx, ZMQ_STREAM); rbind = zmq_socket (ctx, ZMQ_STREAM);
assert (rbind); assert (rbind);
ret = zmq_setsockopt (rbind, ZMQ_STREAM_NOTIFY, &disabled, sizeof (disabled));
assert (ret == 0);
ret = zmq_setsockopt (rbind, ZMQ_LINGER, &zero, sizeof (zero)); ret = zmq_setsockopt (rbind, ZMQ_LINGER, &zero, sizeof (zero));
assert (0 == ret); assert (0 == ret);
ret = zmq_bind (rbind, bindip); ret = zmq_bind (rbind, bindip);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment