Chops Net IP
|
Classes that implement a connect timeout function object interface for the tcp_connector
detail class.
More...
#include <cstddef>
#include <cmath>
#include <chrono>
#include <optional>
#include <functional>
Go to the source code of this file.
Classes | |
struct | chops::net::simple_timeout |
struct | chops::net::counted_timeout |
struct | chops::net::backoff_timeout |
struct | chops::net::exponential_backoff_timeout |
Typedefs | |
using | chops::net::optional_millis = std::optional<std::chrono::milliseconds> |
using | chops::net::tcp_connector_timeout_func = std::function< optional_millis (std::size_t) > |
Classes that implement a connect timeout function object interface for the tcp_connector
detail class.
All classes implement a functor with the following interface:
The return value is the number of milliseconds for the TCP connector timeout, if present. If the value is not present, no further TCP connects are attempted.
The connect_attempts
parameter is the number of connect attempts made by the TCP connector. It will always be greater than zero.
The following use cases are supported: 1) always return the same timeout (i.e. no scale factor, no backoff); 2) scale the timeout by a multiplier or exponential factor for each connect attempt, cap the timeout at a max timeout value; 3) stop after N connect attempts.
Other use cases can be implemented by applications providing a function object or lambda in the make_tcp_connector
method call.
The TCP connector uses a copy of the initial timeout function object when connection attempts are started. In other words, if a TCP connection is brought down due to a network error and the "re-connect on error" flag is set true
in the make_tcp_connector
call, then the timeout function object will start in the initial state (as supplied). This may make a difference for function objects that need to modify state. None of the functor classes in this header modify state.
Copyright (c) 2019 by Cliff Green, Nathan Deutsch
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)