2
Copyright (c) 2011 250bpm s.r.o.
3
Copyright (c) 2011 Other contributors as noted in the AUTHORS file
5
This file is part of 0MQ.
7
0MQ is free software; you can redistribute it and/or modify it under
8
the terms of the GNU Lesser General Public License as published by
9
the Free Software Foundation; either version 3 of the License, or
10
(at your option) any later version.
12
0MQ is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef __IPC_CONNECTER_HPP_INCLUDED__
22
#define __IPC_CONNECTER_HPP_INCLUDED__
24
#include "platform.hpp"
26
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
31
#include "io_object.hpp"
40
class ipc_connecter_t : public own_t, public io_object_t
44
// If 'delay' is true connecter first waits for a while, then starts
45
// connection process.
46
ipc_connecter_t (zmq::io_thread_t *io_thread_,
47
zmq::session_base_t *session_, const options_t &options_,
48
const address_t *addr_, bool delay_);
53
// ID of the timer used to delay the reconnection.
54
enum {reconnect_timer_id = 1};
56
// Handlers for incoming commands.
59
// Handlers for I/O events.
62
void timer_event (int id_);
64
// Internal function to start the actual connection establishment.
65
void start_connecting ();
67
// Internal function to add a reconnect timer
68
void add_reconnect_timer();
70
// Internal function to return a reconnect backoff delay.
71
// Will modify the current_reconnect_ivl used for next call
72
// Returns the currently used interval
73
int get_new_reconnect_ivl ();
75
// Open IPC connecting socket. Returns -1 in case of error,
76
// 0 if connect was successfull immediately. Returns -1 with
77
// EAGAIN errno if async connect was launched.
80
// Close the connecting socket.
83
// Get the file descriptor of newly created connection. Returns
84
// retired_fd if the connection was unsuccessfull.
87
// Address to connect to. Owned by session_base_t.
88
const address_t *addr;
93
// Handle corresponding to the listening socket.
96
// If true file descriptor is registered with the poller and 'handle'
97
// contains valid value.
100
// If true, connecter is waiting a while before trying to connect.
103
// Reference to the session we belong to.
104
zmq::session_base_t *session;
106
// Current reconnect ivl, updated for backoff strategy
107
int current_reconnect_ivl;
109
// String representation of endpoint to connect to
110
std::string endpoint;
112
ipc_connecter_t (const ipc_connecter_t&);
113
const ipc_connecter_t &operator = (const ipc_connecter_t&);