SNode.C
Loading...
Searching...
No Matches
net::in::stream::config::ConfigSocketServer Class Reference

#include <ConfigSocketServer.h>

Inheritance diagram for net::in::stream::config::ConfigSocketServer:
Collaboration diagram for net::in::stream::config::ConfigSocketServer:

Public Member Functions

ConfigSocketServersetReuseAddress (bool reuseAddress=true)
bool getReuseAddress () const
ConfigSocketServersetReusePort (bool reusePort=true)
bool getReusePort () const
ConfigSocketServersetDisableNagleAlgorithm (bool disableNagleAlgorithm=true)
bool getDisableNagleAlgorithm () const
Public Member Functions inherited from net::in::config::ConfigAddress< net::config::ConfigAddressLocal >
SocketAddress getSocketAddress (const SocketAddress::SockAddr &sockAddr, SocketAddress::SockLen sockAddrLen)
ConfigAddresssetSocketAddress (const SocketAddress &socketAddress)
ConfigAddresssetHost (const std::string &ipOrHostname)
std::string getHost () const
ConfigAddresssetPort (uint16_t port)
uint16_t getPort () const
ConfigAddresssetNumeric (bool numeric=true)
bool getNumeric () const
ConfigAddresssetNumericReverse (bool numeric=true)
bool getNumericReverse () const
void configurable (bool configurable=true) final
Public Member Functions inherited from net::config::ConfigSection
template<typename T>
 ConfigSection (ConfigInstance *instance, T *sectionPtr, const std::string &group="Sections")
 ~ConfigSection () override
 ConfigSection (const ConfigSection &)=delete
 ConfigSection (ConfigSection &&)=delete
ConfigSectionoperator= (const ConfigSection &)=delete
Public Member Functions inherited from utils::SubCommand
 SubCommand (const SubCommand &)=delete
 SubCommand (SubCommand &&)=delete
SubCommandoperator= (const SubCommand &)=delete
SubCommandoperator= (SubCommand &&)=delete
virtual ~SubCommand ()
std::string getName () const
std::string version () const
void parse (int argc, char *argv[])
CLI::Option * setConfig (const std::string &defaultConfigFile) const
CLI::Option * setLogFile (const std::string &defaultLogFile) const
CLI::Option * setVersionFlag (const std::string &version) const
bool hasParent () const
SubCommandgetParent ()
SubCommandallowExtras (bool allow=true)
SubCommandrequired (bool required=true, bool force=true)
SubCommandrequired (SubCommand *subCommand, bool required=true)
SubCommandrequired (CLI::Option *option, bool required=true)
SubCommandneeds (SubCommand *subCommand, bool needs=true)
SubCommanddisabled (SubCommand *subCommand, bool disabled=true)
SubCommandsetRequireCallback (const std::function< void(void)> &callback)
SubCommandfinalCallback (const std::function< void()> &finalCallback)
std::string configToStr () const
std::string help (const CLI::App *helpApp, const CLI::AppFormatMode &mode) const
template<typename NewSubCommand, typename... Args>
NewSubCommand * newSubCommand (Args &&... args)
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand ()
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand () const
CLI::Option * getOption (const std::string &name) const
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOptionVariable (const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator) const
template<typename ValueTypeT>
CLI::Option * addOptionVariable (const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &additionalValidator) const
CLI::Option * addOptionFunction (const std::string &name, std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOptionFunction (const std::string &name, std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator)
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator)
Public Member Functions inherited from net::config::ConfigAddress< net::in::SocketAddress >
net::in::SocketAddress getSocketAddress (const typename net::in::SocketAddress::SockAddr &sockAddr, typename net::in::SocketAddress::SockLen sockAddrLen)
void renew ()
Public Member Functions inherited from net::config::ConfigAddressBase< net::in::SocketAddress >
net::in::SocketAddress getSocketAddress (const typename net::in::SocketAddress::SockAddr &sockAddr, typename net::in::SocketAddress::SockLen sockAddrLen)
Public Member Functions inherited from net::in::config::ConfigAddressReverse< net::config::ConfigAddressReverse >
SocketAddress getSocketAddress (const SocketAddress::SockAddr &sockAddr, SocketAddress::SockLen sockAddrLen)
ConfigAddressReversesetNumericReverse (bool numeric=true)
bool getNumericReverse () const
Public Member Functions inherited from net::config::ConfigConnection
utils::Timeval getReadTimeout () const
ConfigConnectionsetReadTimeout (const utils::Timeval &newReadTimeoutSet)
utils::Timeval getWriteTimeout () const
ConfigConnectionsetWriteTimeout (const utils::Timeval &newWriteTimeoutSet)
std::size_t getReadBlockSize () const
ConfigConnectionsetReadBlockSize (std::size_t newReadBlockSize)
std::size_t getWriteBlockSize () const
ConfigConnectionsetWriteBlockSize (std::size_t newWriteBlockSize)
utils::Timeval getTerminateTimeout () const
ConfigConnectionsetTerminateTimeout (const utils::Timeval &newTerminateTimeout)
Public Member Functions inherited from net::config::ConfigPhysicalSocketServer
ConfigPhysicalSocketServersetBacklog (int newBacklog)
int getBacklog () const
ConfigPhysicalSocketServersetAcceptsPerTick (int acceptsPerTickSet)
int getAcceptsPerTick () const
ConfigPhysicalSocketServersetAcceptTimeout (const utils::Timeval &acceptTimeout)
utils::Timeval getAcceptTimeout () const
Public Member Functions inherited from net::config::ConfigPhysicalSocket
const std::map< int, std::map< int, net::phy::PhysicalSocketOption > > & getSocketOptions () const
ConfigPhysicalSocketaddSocketOption (int optLevel, int optName, int optValue)
ConfigPhysicalSocketaddSocketOption (int optLevel, int optName, const std::string &optValue)
ConfigPhysicalSocketaddSocketOption (int optLevel, int optName, const std::vector< char > &optValue)
ConfigPhysicalSocketremoveSocketOption (int optLevel, int optName)
ConfigPhysicalSocketsetRetry (bool retry=true)
bool getRetry () const
ConfigPhysicalSocketsetRetryOnFatal (bool retry=true)
bool getRetryOnFatal () const
ConfigPhysicalSocketsetRetryTimeout (double sec)
double getRetryTimeout () const
ConfigPhysicalSocketsetRetryTries (unsigned int tries=0)
unsigned int getRetryTries () const
ConfigPhysicalSocketsetRetryBase (double base)
double getRetryBase () const
ConfigPhysicalSocketsetRetryLimit (unsigned int limit)
unsigned int getRetryLimit () const
ConfigPhysicalSocketsetRetryJitter (double percent)
double getRetryJitter () const
template<typename ConcretConfigPhysicalSocket>
 ConfigPhysicalSocket (ConfigInstance *instance, ConcretConfigPhysicalSocket *section)

Protected Member Functions

 ConfigSocketServer (net::config::ConfigInstance *instance)
 ~ConfigSocketServer () override
Protected Member Functions inherited from net::config::stream::ConfigSocketServer< net::in::config::ConfigAddress, net::in::config::ConfigAddressReverse >
 ConfigSocketServer (net::config::ConfigInstance *instance)
Protected Member Functions inherited from net::in::config::ConfigAddress< net::config::ConfigAddressLocal >
 ConfigAddress (net::config::ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
ConfigAddresssetAiFlags (int aiFlags)
int getAiFlags () const
ConfigAddresssetAiSockType (int aiSockType)
int getAiSockType () const
ConfigAddresssetAiProtocol (int aiProtocol)
int getAiProtocol () const
ConfigAddresssetHostRequired (bool required=true)
ConfigAddresssetPortRequired (bool required=true)
Protected Member Functions inherited from utils::SubCommand
 SubCommand (SubCommand *parent, std::shared_ptr< utils::AppWithPtr > appWithPtr, const std::string &group, bool final)
template<typename ConcretSubCommand>
 SubCommand (SubCommand *parent, ConcretSubCommand *concretSubCommand, const std::string &group, bool final=true)
SubCommanddescription (const std::string &description)
SubCommandfooter (const std::string &footer)
template<typename ValueTypeT>
CLI::Option * setDefaultValue (CLI::Option *option, const ValueTypeT &value, bool clear=true) const
CLI::Option * setConfigurable (CLI::Option *option, bool configurable) const
Protected Member Functions inherited from net::config::ConfigAddress< net::in::SocketAddress >
 ConfigAddress (ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
 ~ConfigAddress () override
Protected Member Functions inherited from net::config::ConfigAddressBase< net::in::SocketAddress >
 ConfigAddressBase (ConfigInstance *instance, const std::string &addressOptionName="", const std::string &addressOptionDescription="")
virtual ~ConfigAddressBase ()=default
Protected Member Functions inherited from net::in::config::ConfigAddressReverse< net::config::ConfigAddressReverse >
 ConfigAddressReverse (net::config::ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
Protected Member Functions inherited from net::config::ConfigConnection
 ConfigConnection (ConfigInstance *instance)
 ~ConfigConnection () override
Protected Member Functions inherited from net::config::ConfigPhysicalSocketServer
 ConfigPhysicalSocketServer (ConfigInstance *instance)
 ~ConfigPhysicalSocketServer () override
Protected Member Functions inherited from net::config::ConfigPhysicalSocket
template<typename ConcretConfigPhysicalSocketT>
 ConfigPhysicalSocket (ConfigInstance *instance, ConcretConfigPhysicalSocketT *section)
 ~ConfigPhysicalSocket () override
CLI::Option * addSocketOption (const std::string &name, int optLevel, int optName, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator)

Private Attributes

CLI::Option * reuseAddressOpt = nullptr
CLI::Option * reusePortOpt = nullptr
CLI::Option * disableNagleAlgorithmOpt = nullptr

Additional Inherited Members

Public Types inherited from net::config::stream::ConfigSocketServer< net::in::config::ConfigAddress, net::in::config::ConfigAddressReverse >
using Local
using Remote
using Connection
using Socket
Static Public Member Functions inherited from utils::SubCommand
static CLI::App * getHelpTriggerApp ()
static CLI::App * getShowConfigTriggerApp ()
static CLI::App * getCommandlineTriggerApp ()
Static Public Attributes inherited from utils::SubCommand
static std::shared_ptr< CLI::Formatter > sectionFormatter = makeSectionFormatter()
Static Public Attributes inherited from net::config::ConfigAddressLocal< net::in::SocketAddress >
static constexpr std::string_view NAME
static constexpr std::string_view DESCRIPTION
Static Public Attributes inherited from net::config::ConfigAddressReverse< net::in::SocketAddress >
static constexpr std::string_view NAME
static constexpr std::string_view DESCRIPTION
Static Public Attributes inherited from net::config::ConfigConnection
static constexpr std::string_view NAME {"connection"}
static constexpr std::string_view DESCRIPTION {"Configuration of established connections"}
Static Public Attributes inherited from net::config::ConfigPhysicalSocket
static constexpr std::string_view NAME {"socket"}
static constexpr std::string_view DESCRIPTION {"Configuration of socket behavior"}
Static Protected Attributes inherited from utils::SubCommand
static std::map< std::string, std::string > aliases
static CLI::App * helpTriggerApp = nullptr
static CLI::App * showConfigTriggerApp = nullptr
static CLI::App * commandlineTriggerApp = nullptr

Detailed Description

Definition at line 58 of file ConfigSocketServer.h.

Constructor & Destructor Documentation

◆ ConfigSocketServer()

net::in::stream::config::ConfigSocketServer::ConfigSocketServer ( net::config::ConfigInstance * instance)
explicitprotected

Definition at line 60 of file ConfigSocketServer.cpp.

61 : net::config::stream::ConfigSocketServer<net::in::config::ConfigAddress, net::in::config::ConfigAddressReverse>(instance) {
63 Local::setAiFlags(AI_PASSIVE);
64 Local::setAiSockType(SOCK_STREAM);
65 Local::setAiProtocol(IPPROTO_TCP);
66
68 "--reuse-address{true}",
69 SOL_SOCKET,
70 SO_REUSEADDR,
71 "Reuse socket address",
72 "bool",
73 XSTR(IN_REUSE_ADDRESS),
74 CLI::IsMember({"true", "false"}));
75
77 "--reuse-port{true}",
78 SOL_SOCKET,
79 SO_REUSEPORT,
80 "Reuse port number",
81 "bool",
82 XSTR(IN_REUSE_PORT),
83 CLI::IsMember({"true", "false"}));
84
86 "--disable-nagle-algorithm{true}",
87 IPPROTO_TCP,
88 TCP_NODELAY,
89 "Turn of Nagle algorithm",
90 "tristat",
91 XSTR(IN_SERVER_DISABLE_NAGLE_ALGORITHM),
92 CLI::IsMember({"true", "false", "default"}));
93 if (std::string(XSTR(IN6_SERVER_DISABLE_NAGLE_ALGORITHM)) == "default") {
95 }
96 }
#define XSTR(s)
ConfigPhysicalSocket & addSocketOption(int optLevel, int optName, int optValue)
CLI::Option * setDefaultValue(CLI::Option *option, const ValueTypeT &value, bool clear=true) const
Definition SubCommand.h:337

References net::config::ConfigPhysicalSocket::addSocketOption(), net::config::stream::ConfigSocketServer< ConfigAddressLocalT, ConfigAddressRemoteT >::ConfigSocketServer(), disableNagleAlgorithmOpt, reuseAddressOpt, reusePortOpt, net::in::config::ConfigAddress< ConfigAddressTypeT >::setAiFlags(), net::in::config::ConfigAddress< ConfigAddressTypeT >::setAiProtocol(), net::in::config::ConfigAddress< ConfigAddressTypeT >::setAiSockType(), utils::SubCommand::setDefaultValue(), and net::in::config::ConfigAddress< ConfigAddressTypeT >::setPortRequired().

Here is the call graph for this function:

◆ ~ConfigSocketServer()

net::in::stream::config::ConfigSocketServer::~ConfigSocketServer ( )
overrideprotected

Definition at line 98 of file ConfigSocketServer.cpp.

98 {
99 }

Member Function Documentation

◆ getDisableNagleAlgorithm()

bool net::in::stream::config::ConfigSocketServer::getDisableNagleAlgorithm ( ) const

Definition at line 145 of file ConfigSocketServer.cpp.

145 {
146 return disableNagleAlgorithmOpt->as<bool>();
147 }

References disableNagleAlgorithmOpt.

◆ getReuseAddress()

bool net::in::stream::config::ConfigSocketServer::getReuseAddress ( ) const

Definition at line 113 of file ConfigSocketServer.cpp.

113 {
114 return reuseAddressOpt->as<bool>();
115 }

References reuseAddressOpt.

◆ getReusePort()

bool net::in::stream::config::ConfigSocketServer::getReusePort ( ) const

Definition at line 129 of file ConfigSocketServer.cpp.

129 {
130 return reusePortOpt->as<bool>();
131 }

References reusePortOpt.

◆ setDisableNagleAlgorithm()

ConfigSocketServer & net::in::stream::config::ConfigSocketServer::setDisableNagleAlgorithm ( bool disableNagleAlgorithm = true)

Definition at line 133 of file ConfigSocketServer.cpp.

133 {
134 if (disableNagleAlgorithm) {
135 addSocketOption(IPPROTO_TCP, TCP_NODELAY, 1);
136 } else {
137 addSocketOption(IPPROTO_TCP, TCP_NODELAY, 0);
138 }
139
140 Local::setDefaultValue(disableNagleAlgorithmOpt, disableNagleAlgorithm ? "true" : "false");
141
142 return *this;
143 }

References net::config::ConfigPhysicalSocket::addSocketOption(), disableNagleAlgorithmOpt, and utils::SubCommand::setDefaultValue().

Here is the call graph for this function:

◆ setReuseAddress()

ConfigSocketServer & net::in::stream::config::ConfigSocketServer::setReuseAddress ( bool reuseAddress = true)

Definition at line 101 of file ConfigSocketServer.cpp.

101 {
102 if (reuseAddress) {
103 addSocketOption(SOL_SOCKET, SO_REUSEADDR, 1);
104 } else {
105 addSocketOption(SOL_SOCKET, SO_REUSEADDR, 0);
106 }
107
108 Local::setDefaultValue(reuseAddressOpt, reuseAddress ? "true" : "false");
109
110 return *this;
111 }

References net::config::ConfigPhysicalSocket::addSocketOption(), reuseAddressOpt, and utils::SubCommand::setDefaultValue().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setReusePort()

ConfigSocketServer & net::in::stream::config::ConfigSocketServer::setReusePort ( bool reusePort = true)

Definition at line 117 of file ConfigSocketServer.cpp.

117 {
118 if (reusePort) {
119 addSocketOption(SOL_SOCKET, SO_REUSEPORT, 1);
120 } else {
121 addSocketOption(SOL_SOCKET, SO_REUSEPORT, 0);
122 }
123
124 Local::setDefaultValue(reusePortOpt, reusePort ? "true" : "false");
125
126 return *this;
127 }

References net::config::ConfigPhysicalSocket::addSocketOption(), reusePortOpt, and utils::SubCommand::setDefaultValue().

Here is the call graph for this function:

Member Data Documentation

◆ disableNagleAlgorithmOpt

CLI::Option* net::in::stream::config::ConfigSocketServer::disableNagleAlgorithmOpt = nullptr
private

◆ reuseAddressOpt

CLI::Option* net::in::stream::config::ConfigSocketServer::reuseAddressOpt = nullptr
private

Definition at line 76 of file ConfigSocketServer.h.

Referenced by ConfigSocketServer(), getReuseAddress(), and setReuseAddress().

◆ reusePortOpt

CLI::Option* net::in::stream::config::ConfigSocketServer::reusePortOpt = nullptr
private

Definition at line 77 of file ConfigSocketServer.h.

Referenced by ConfigSocketServer(), getReusePort(), and setReusePort().


The documentation for this class was generated from the following files: