![]() |
PIP 5.6.1
Platform-Independent Primitives
|
TCP server implementation for client-server communication. Accepts incoming connections and manages multiple clients with configurable factory for client instance creation. More...
#include <piclientserver_server.h>

Public Member Functions | |
| Server () | |
| Constructs a stopped server with default limits. | |
| virtual | ~Server () |
| Stops the server and releases transport resources. | |
| void | listen (PINetworkAddress addr) |
| Starts listening for clients on address "addr". | |
| void | listenAll (ushort port) |
| Starts listening on all interfaces at port "port". More... | |
| void | stopServer () |
| Stops accepting clients and shuts the server down. | |
| void | closeAll () |
| Closes all currently connected clients. More... | |
| int | getMaxClients () const |
| Returns the configured maximum number of simultaneous clients. | |
| void | setMaxClients (int new_max_clients) |
| Sets the maximum number of simultaneous clients. More... | |
| int | clientsCount () const |
| Returns the number of currently connected clients. | |
| void | forEachClient (std::function< void(ServerClient *)> func) |
| Calls "func" for each currently connected client. | |
| void | setClientFactory (std::function< ServerClient *()> f) |
| Sets the factory used to create accepted client objects. | |
Public Member Functions inherited from PIStreamPackerConfig | |
| PIStreamPackerConfig () | |
| Constructs configuration with default packet framing parameters. | |
| void | setMaxPacketSize (int max_size) |
| Sets maximum size of one emitted frame chunk. | |
| int | maxPacketSize () const |
| Returns maximum size of one emitted frame chunk. | |
| void | setPacketSign (ushort sign_) |
| Sets packet signature used to detect frame boundaries. | |
| ushort | packetSign () const |
| Returns packet signature. | |
| void | setaAggressiveOptimization (bool yes) |
| Enables faster resynchronization on invalid stream data. More... | |
| bool | aggressiveOptimization () const |
| Returns whether aggressive resynchronization is enabled. | |
| bool | cryptSizeEnabled () const |
| Returns whether packet size field is encrypted too. | |
| void | setCryptSizeEnabled (bool on) |
| Enables or disables encryption of the packet size field. | |
| const PIStreamPackerConfig & | configuration () const |
| Returns configuration as a const self-reference. | |
| PIStreamPackerConfig & | configuration () |
| Returns configuration as a mutable self-reference. | |
| void | setConfiguration (const PIStreamPackerConfig &config) |
| Replaces current framing configuration with "config". | |
Public Member Functions inherited from PIEthUtilBase | |
| PIEthUtilBase () | |
| Constructs helper with crypt layer disabled. | |
| ~PIEthUtilBase () | |
| Destroys the crypt helper. | |
| void | setCryptEnabled (bool on) |
| Enables or disables the crypt layer. | |
| void | cryptEnable () |
| Enables the crypt layer. | |
| void | cryptDisable () |
| Disables the crypt layer. | |
| bool | isCryptEnabled () const |
| Returns whether the crypt layer is enabled. | |
| void | setCryptKey (const PIByteArray &k) |
| Sets crypt key "k" and enables the crypt layer. | |
| void | createCryptKey (const PIString &k) |
| Generates crypt key from passphrase "k" and enables the crypt layer. | |
| PIByteArray | cryptKey () const |
| Returns current crypt key. | |
Additional Inherited Members | |
Static Public Member Functions inherited from PIEthUtilBase | |
| static size_t | cryptSizeAddition () |
| Returns extra size added by encryption. | |
Protected Member Functions inherited from PIEthUtilBase | |
| PIByteArray | cryptData (const PIByteArray &data) |
| Encrypts "data" when the crypt layer is enabled. | |
| PIByteArray | decryptData (const PIByteArray &data) |
| Decrypts "data" when the crypt layer is enabled. More... | |
TCP server implementation for client-server communication. Accepts incoming connections and manages multiple clients with configurable factory for client instance creation.
|
inline |
Starts listening on all interfaces at port "port".
Equivalent to listen({0, port}), binds to all available network interfaces.
| void PIClientServer::Server::closeAll | ( | ) |
Closes all currently connected clients.
Immediately closes all active client connections without stopping the server.
| void PIClientServer::Server::setMaxClients | ( | int | new_max_clients | ) |
Sets the maximum number of simultaneous clients.
Sets the maximum number of concurrent client connections. Default is 1000.