CatapultServer  v0.5.0.1 (Elephant)
AsyncTcpServer.h
Go to the documentation of this file.
1 
21 #pragma once
23 
24 namespace catapult { namespace thread { class IoThreadPool; } }
25 
26 namespace catapult { namespace net {
27 
29 
31 
34  public:
36  explicit AsyncTcpServerSettings(const AcceptHandler& accept);
37 
38  public:
41 
42  // The configure socket handler.
44 
47 
48  // The maximum number of pending connections (backlog size).
49  uint16_t MaxPendingConnections = 100;
50 
51  // The maximum number of active connections.
52  uint32_t MaxActiveConnections = 25;
53 
55  bool AllowAddressReuse = false;
56  };
57 
60  public:
61  virtual ~AsyncTcpServer() = default;
62 
63  public:
65  virtual uint32_t numPendingAccepts() const = 0;
66 
68  virtual uint32_t numCurrentConnections() const = 0;
69 
71  virtual uint32_t numLifetimeConnections() const = 0;
72 
73  public:
75  virtual void shutdown() = 0;
76  };
77 
80  std::shared_ptr<AsyncTcpServer> CreateAsyncTcpServer(
81  const std::shared_ptr<thread::IoThreadPool>& pPool,
82  const boost::asio::ip::tcp::endpoint& endpoint,
83  const AsyncTcpServerSettings& settings);
84 }}
catapult::net::AsyncTcpServerSettings::PacketSocketOptions
ionet::PacketSocketOptions PacketSocketOptions
Packet socket options.
Definition: AsyncTcpServer.h:46
catapult::net::ConfigureSocketHandler
consumer< ionet::socket & > ConfigureSocketHandler
Definition: AsyncTcpServer.h:30
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
m_isStopped
std::atomic_bool m_isStopped
Definition: AsyncTcpServer.cpp:204
catapult::net::ConnectionSettings::toSocketOptions
ionet::PacketSocketOptions toSocketOptions() const
Gets the packet socket options represented by the configured settings.
Definition: ConnectionSettings.h:68
catapult::net::AsyncTcpServer::numCurrentConnections
virtual uint32_t numCurrentConnections() const =0
Current number of active connections.
Parser.debug
def debug(*args)
Definition: Parser.py:46
catapult::net::ConnectionSettings
Settings used to configure connections.
Definition: ConnectionSettings.h:31
catapult::net::AsyncTcpServer::numPendingAccepts
virtual uint32_t numPendingAccepts() const =0
Number of asynchronously started (but not completed) socket accepts.
m_pPool
std::shared_ptr< thread::IoThreadPool > m_pPool
Definition: AsyncTcpServer.cpp:199
catapult::net::AsyncTcpServerSettings::MaxPendingConnections
uint16_t MaxPendingConnections
Definition: AsyncTcpServer.h:49
catapult::net::AsyncTcpServerSettings::AllowAddressReuse
bool AllowAddressReuse
true if the server should reuse ports already in use.
Definition: AsyncTcpServer.h:55
m_settings
const AsyncTcpServerSettings m_settings
Definition: AsyncTcpServer.cpp:203
catapult::net::AsyncTcpServer
An async TCP server.
Definition: AsyncTcpServer.h:59
m_acceptorStrand
boost::asio::io_context::strand m_acceptorStrand
Definition: AsyncTcpServer.cpp:200
m_numPendingAccepts
std::atomic< uint32_t > m_numPendingAccepts
Definition: AsyncTcpServer.cpp:205
catapult::net::AsyncTcpServerSettings::AsyncTcpServerSettings
AsyncTcpServerSettings(const AcceptHandler &accept)
Creates a structure with a preconfigured accept handler (accept).
Definition: AsyncTcpServer.cpp:211
catapult::net::AsyncTcpServer::shutdown
virtual void shutdown()=0
Shuts down the server.
catapult::net::AsyncTcpServer::~AsyncTcpServer
virtual ~AsyncTcpServer()=default
catapult::net::AcceptHandler
consumer< const ionet::AcceptedPacketSocketInfo & > AcceptHandler
Definition: AsyncTcpServer.h:28
PacketSocket.h
m_numCurrentConnections
std::atomic< uint32_t > m_numCurrentConnections
Definition: AsyncTcpServer.cpp:206
catapult::net::AsyncTcpServer::numLifetimeConnections
virtual uint32_t numLifetimeConnections() const =0
Total number of connections during the server's lifetime.
IoThreadPool.h
ConnectionSettings.h
forwardsValidation.info
def info(*args)
Definition: forwardsValidation.py:12
AsyncTcpServer.h
catapult::net::CreateAsyncTcpServer
std::shared_ptr< AsyncTcpServer > CreateAsyncTcpServer(const std::shared_ptr< thread::IoThreadPool > &pPool, const boost::asio::ip::tcp::endpoint &endpoint, const AsyncTcpServerSettings &settings)
Definition: AsyncTcpServer.cpp:217
catapult::ionet::Accept
void Accept(boost::asio::ip::tcp::acceptor &acceptor, const PacketSocketOptions &options, const ConfigureSocketCallback &configureSocket, const AcceptCallback &accept)
Definition: PacketSocket.cpp:377
catapult::net::AsyncTcpServerSettings::ConfigureSocket
ConfigureSocketHandler ConfigureSocket
Definition: AsyncTcpServer.h:43
catapult::net::AsyncTcpServerSettings::MaxActiveConnections
uint32_t MaxActiveConnections
Definition: AsyncTcpServer.h:52
catapult::net::AsyncTcpServerSettings
Settings used to configure AsyncTcpServer behavior.
Definition: AsyncTcpServer.h:33
pSocket
SocketPointer pSocket
Definition: PacketWriters.cpp:46
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::ionet::PacketSocketOptions
Packet socket options.
Definition: PacketSocketOptions.h:27
Logging.h
m_acceptor
boost::asio::ip::tcp::acceptor m_acceptor
Definition: AsyncTcpServer.cpp:201
catapult::net::AsyncTcpServerSettings::Accept
const AcceptHandler Accept
Accept handler (must be set via constructor).
Definition: AsyncTcpServer.h:40
catapult::consumer
std::function< void(TArgs...)> consumer
A consumer function.
Definition: functions.h:35
m_numLifetimeConnections
std::atomic< uint32_t > m_numLifetimeConnections
Definition: AsyncTcpServer.cpp:207