TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
Loading...
Searching...
No Matches
tec::SocketServerParams Struct Reference

Parameters specific to server-side socket configuration. More...

#include <tec_socket.hpp>

Inheritance diagram for tec::SocketServerParams:
tec::SocketParams

Public Member Functions

 SocketServerParams ()
 Default constructor.
 
- Public Member Functions inherited from tec::SocketParams
 SocketParams ()
 Default constructor.
 

Public Attributes

int mode
 Data handling mode (character stream or binary network data).
 
int queue_size
 Maximum backlog for listen().
 
int opt_reuse_addr
 Whether to set SO_REUSEADDR (0 = no, 1 = yes).
 
int opt_reuse_port
 Whether to set SO_REUSEPORT (if available).
 
bool use_thread_pool
 Use the thread pool for handling accepted connections.
 
size_t thread_pool_size
 Number of threads in the thread pool.
 
- Public Attributes inherited from tec::SocketParams
std::string addr
 Target address or hostname.
 
int port
 Port number to connect to or bind.
 
int family
 Address family (AF_INET, AF_INET6, AF_UNSPEC, ...).
 
int socktype
 Socket type (SOCK_STREAM, SOCK_DGRAM, ...).
 
int protocol
 Protocol (usually 0).
 
int flags
 Flags passed to getaddrinfo().
 
int compression
 Compression algorithm to use (see CompressionParams).
 
int compression_level
 Compression level [0..9] (higher = better compression, slower).
 
size_t compression_min_size
 Minimum size of data to apply compression (bytes).
 
size_t buffer_size
 Buffer size for using in send/recv operations (bytes).
 

Static Public Attributes

static constexpr int kOptReuseAddress {0}
 Disable SO_REUSEADDR option.
 
static constexpr int kOptReusePort {1}
 Enable SO_REUSEADDR and SO_REUSEPORT (if supported).
 
static constexpr int kModeCharStream {0}
 Treat incoming data as null-terminated character streams.
 
static constexpr int kModeNetData {1}
 Treat incoming data as length-prefixed binary network messages.
 
static constexpr int kDefaultMode {kModeCharStream}
 Default data handling mode.
 
static constexpr int kDefaultMaxThreads {16}
 Default maximum number of threads in a custom thread pool.
 
static constexpr int kDefaultConnQueueSize {SOMAXCONN}
 Maximum length of the pending connections queue for listen(). Usually 4096.
 
static constexpr bool kUseThreadPool {false}
 Whether to use a fixed-size thread pool instead of one-thread-per-connection.
 
- Static Public Attributes inherited from tec::SocketParams
static constexpr char kAnyAddr [] {"0.0.0.0"}
 IPv4 address to bind/accept connections from any interface.
 
static constexpr char kLocalAddr [] {"127.0.0.1"}
 IPv4 loopback address (localhost).
 
static constexpr char kLocalURI [] {"localhost"}
 Hostname that resolves to localhost for both IPv4 and IPv6.
 
static constexpr char kAnyAddrIP6 [] {"::"}
 IPv6 address to bind/accept connections from any interface.
 
static constexpr char kLocalAddrIP6 [] {"::1"}
 IPv6 loopback address (localhost).
 
static constexpr int kDefaultPort {4321}
 Default port number used for testing and examples.
 
static constexpr int kDefaultFamily {AF_UNSPEC}
 Default address family: AF_UNSPEC allows both IPv4 and IPv6.
 
static constexpr int kDefaultSockType {SOCK_STREAM}
 Default socket type: TCP stream socket.
 
static constexpr int kDefaultProtocol {0}
 Default protocol: 0 means "any appropriate protocol".
 
static constexpr int kDefaultServerFlags {AI_PASSIVE}
 Default addrinfo flags for server sockets (bind to local address).
 
static constexpr int kDefaultClientFlags {0}
 Default addrinfo flags for client sockets (no special behaviour).
 
static constexpr char kNullChar {0}
 Null character constant (for internal use).
 
static constexpr size_t kDefaultBufSize {BUFSIZ}
 Default buffer size as defined in stdio.h (8192).
 

Detailed Description

Parameters specific to server-side socket configuration.

Extends SocketParams with server-specific options such as listen queue size, socket reuse options, threading model, and data handling mode.

Constructor & Destructor Documentation

◆ SocketServerParams()

tec::SocketServerParams::SocketServerParams ( )
inline

Default constructor.

Initializes with server-appropriate defaults:

  • Binds to any IPv4 address (0.0.0.0)
  • Uses AI_PASSIVE flag
  • Sets thread pool size to hardware concurrency

Member Data Documentation

◆ kDefaultConnQueueSize

constexpr int tec::SocketServerParams::kDefaultConnQueueSize {SOMAXCONN}
staticconstexpr

Maximum length of the pending connections queue for listen(). Usually 4096.

If a connection request arrives when the queue is full, the client may receive ECONNREFUSED or the request may be ignored (depending on protocol).


The documentation for this struct was generated from the following file: