20 #ifndef INCLUDE_OLA_NETWORK_ADVANCEDTCPCONNECTOR_H_ 21 #define INCLUDE_OLA_NETWORK_ADVANCEDTCPCONNECTOR_H_ 27 #include <ola/io/SelectServerInterface.h> 28 #include <ola/network/TCPConnector.h> 29 #include <ola/network/TCPSocketFactory.h> 30 #include <ola/util/Backoff.h> 108 unsigned int *failed_attempts)
const;
126 unsigned int failed_attempts;
133 typedef std::pair<IPV4Address, uint16_t> IPPortPair;
134 typedef std::map<IPPortPair, ConnectionInfo*> ConnectionMap;
140 ConnectionMap m_connections;
142 void ScheduleRetry(
const IPPortPair &key, ConnectionInfo *info);
143 void RetryTimeout(IPPortPair key);
144 void ConnectionResult(IPPortPair key,
int fd,
int error);
145 void AttemptConnection(
const IPPortPair &key, ConnectionInfo *state);
146 void AbortConnection(ConnectionInfo *state);
152 #endif // INCLUDE_OLA_NETWORK_ADVANCEDTCPCONNECTOR_H_ A time interval, with usecond accuracy.
Definition: Clock.h:138
bool GetEndpointState(const IPV4SocketAddress &endpoint, ConnectionState *connected, unsigned int *failed_attempts) const
Get the state & number of failed_attempts for an endpoint.
Definition: AdvancedTCPConnector.cpp:86
void AddEndpoint(const IPV4SocketAddress &endpoint, BackOffPolicy *backoff_policy, bool paused=false)
Add an endpoint to manage a connection to.
Definition: AdvancedTCPConnector.cpp:52
ConnectionState
The state of a connection.
Definition: AdvancedTCPConnector.h:92
void RemoveEndpoint(const IPV4SocketAddress &endpoint)
Remove a IP:Port from the connection manager. This won't close the connection if it's already establi...
Definition: AdvancedTCPConnector.cpp:75
Attempts to open a TCP connection until a failure limit is reached.
Definition: AdvancedTCPConnector.h:48
const void * TCPConnectionID
The TCPConnectionID.
Definition: TCPConnector.h:55
Definition: AdvancedTCPConnector.h:95
Definition: TCPSocketFactory.h:34
An class which manages non-blocking TCP connects.
Definition: TCPConnector.h:40
void * timeout_id
A timeout handle which can later be used to cancel a timeout.
Definition: SchedulerInterface.h:34
The interface for the SelectServer.
Definition: SelectServerInterface.h:42
Definition: AdvancedTCPConnector.h:93
AdvancedTCPConnector(ola::io::SelectServerInterface *ss, TCPSocketFactoryInterface *socket_factory, const ola::TimeInterval &connection_timeout)
Create a new AdvancedTCPConnector.
Definition: AdvancedTCPConnector.cpp:32
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: AdvancedTCPConnector.h:94
void Resume(const IPV4SocketAddress &endpoint)
Resume trying to connect to a ip:port pair.
Definition: AdvancedTCPConnector.cpp:126
An IPv4 SocketAddress.
Definition: SocketAddress.h:78
void Disconnect(const IPV4SocketAddress &endpoint, bool pause=false)
Mark an endpoint as disconnected.
Definition: AdvancedTCPConnector.cpp:100
unsigned int EndpointCount() const
Return the number of connections tracked by this connector.
Definition: AdvancedTCPConnector.h:87