11 #ifndef ZMQ_HAVE_WINDOWS
20 zmq::io_thread_t *io_thread_,
24 bool delayed_start_) :
30 _socket (session_->get_socket ()),
31 _delayed_start (delayed_start_),
32 _reconnect_timer_started (
false),
33 _current_reconnect_ivl (-1),
53 add_reconnect_timer ();
60 if (_reconnect_timer_started) {
61 cancel_timer (reconnect_timer_id);
62 _reconnect_timer_started =
false;
77 if (
options.reconnect_ivl > 0) {
78 const int interval = get_new_reconnect_ivl ();
79 add_timer (interval, reconnect_timer_id);
80 _socket->event_connect_retried (
82 _reconnect_timer_started =
true;
88 if (
options.reconnect_ivl_max > 0) {
89 int candidate_interval = 0;
90 if (_current_reconnect_ivl == -1)
91 candidate_interval =
options.reconnect_ivl;
92 else if (_current_reconnect_ivl > std::numeric_limits<int>::max () / 2)
93 candidate_interval = std::numeric_limits<int>::max ();
95 candidate_interval = _current_reconnect_ivl * 2;
97 if (candidate_interval >
options.reconnect_ivl_max)
98 _current_reconnect_ivl =
options.reconnect_ivl_max;
100 _current_reconnect_ivl = candidate_interval;
101 return _current_reconnect_ivl;
103 if (_current_reconnect_ivl == -1)
104 _current_reconnect_ivl =
options.reconnect_ivl;
108 _current_reconnect_ivl
109 < std::numeric_limits<int>::max () - random_jitter
110 ? _current_reconnect_ivl + random_jitter
111 : std::numeric_limits<int>::max ();
126 #ifdef ZMQ_HAVE_WINDOWS
128 wsa_assert (rc != SOCKET_ERROR);
130 const int rc = ::close (_s);
133 _socket->event_closed (
156 engine =
new (std::nothrow) raw_engine_t (fd_,
options, endpoint_pair);
158 engine =
new (std::nothrow) zmtp_engine_t (fd_,
options, endpoint_pair);
162 send_attach (_session, engine);
167 _socket->event_connected (endpoint_pair, fd_);
173 _reconnect_timer_started =
false;