Commit 97324398 authored by shripchenko's avatar shripchenko Committed by Pieter Hintjens

refactored ZMQ_ROUTER_ANNOUNCE_SELF code. renamed it to ZMQ_PROBE_NEW_PEERS.

implement it for DEALER tocket.
+documentation
parent d5f60369
......@@ -421,21 +421,19 @@ Default value:: 0
Applicable socket types:: ZMQ_ROUTER
ZMQ_PROBE: automatically send empty packet to every established connection
ZMQ_PROBE_NEW_PEERS: automatically send empty packet to every established connection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the compatible sockets behavior to automatically send an empty packet
Sets the 'ROUTER' & 'DEALER' sockets behavior to automatically send an empty packet
to any new connection made (or accepted) by socket. It could help sockets to
auto discovery them-self. It especially important in 'ROUTER' <-> 'ROUTER' connections
auto discovery themself. It especially important in 'ROUTER' <-> 'ROUTER' connections
where it solves 'who will write first' problems.
NOTE: Don't set this options for sockets working with ZMQ_REP, ZMQ_REQ sockets.
It will interfere with their strict synchronous logic and framing.
[horizontal]
Option value type:: int
Option value unit:: 0, 1
Default value:: 0
Applicable socket types:: ZMQ_ROUTER, ZMQ_DEALER, ZMQ_REP, ZMQ_REQ
Applicable socket types:: ZMQ_ROUTER, ZMQ_DEALER
ZMQ_XPUB_VERBOSE: provide all subscription messages on XPUB sockets
......
......@@ -40,14 +40,14 @@ void zmq::dealer_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_)
zmq_assert (pipe_);
if (probe_new_peers) {
int rc;
int rc, ok;
msg_t probe_msg_;
rc = probe_msg_.init ();
errno_assert (rc == 0);
rc = pipe_->write (&probe_msg_);
zmq_assert (rc);
ok = pipe_->write (&probe_msg_);
zmq_assert (ok);
pipe_->flush ();
rc = probe_msg_.close ();
......
......@@ -398,12 +398,15 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_)
rc = probe_msg_.init ();
errno_assert (rc == 0);
rc = pipe_->write (&probe_msg_);
zmq_assert (rc);
ok = pipe_->write (&probe_msg_);
pipe_->flush ();
rc = probe_msg_.close ();
errno_assert (rc == 0);
// Ignore not probed peers
if (!ok)
return false;
}
return true;
......
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