Abstract TCP server supporting both plain-text and TLS/SSL connections.
More...
#include <tcpserver.h>
|
| | TcpServer (const QHostAddress &serverAddress, int serverPort) |
| | Construct a plain-text TCP server.
|
| |
| | TcpServer (const QHostAddress &serverAddress, int serverPort, const QSslKey &privateKey, const QSslCertificate &localCertificate, const QSslCertificate &caCert, bool verifyPeer=false) |
| | Construct an SSL/TLS TCP server with a single CA certificate.
|
| |
| | TcpServer (const QHostAddress &serverAddress, int serverPort, const QSslKey &privateKey, const QSslCertificate &localCertificate, const QList< QSslCertificate > &caCerts, bool verifyPeer=false) |
| | Construct an SSL/TLS TCP server with a list of CA certificates.
|
| |
|
virtual | ~TcpServer () |
| | Destructor — stops the server and cleans up all client connections.
|
| |
| bool | start () |
| | Start the server and begin accepting connections.
|
| |
|
void | stop () |
| | Stop the server and close all active client connections.
|
| |
| QSslKey | privateKey () const |
| | Return the server's private key (SSL mode only).
|
| |
| QSslCertificate | localCertificate () const |
| | Return the server's local certificate (SSL mode only).
|
| |
| QList< QSslCertificate > | caCerts () const |
| | Return the list of CA certificates (SSL mode only).
|
| |
| bool | verifyPeer () const |
| | Return whether peer certificate verification is enabled.
|
| |
| QDateTime | startTime () const |
| | Return the time the server was started.
|
| |
| | LoggingBaseClass (const Log::LogCategory &category=Log::LogCategory()) |
| | Construct with an optional log category.
|
| |
| | LoggingBaseClass (const QString &category) |
| | Construct with a category name string.
|
| |
| Log::LogCategory | logCategory () const |
| | Return the base log category.
|
| |
|
| virtual TcpServerClientObject * | createClient (TcpServer *server, qintptr fd)=0 |
| | Factory method called for each incoming connection.
|
| |
| virtual void | incomingConnection (qintptr handle) override |
| | Handle a new incoming connection by delegating to createClient().
|
| |
| Log::LogCategory | LVL0 () const |
| | Return the base (level 0) log category.
|
| |
| Log::LogCategory | LVL1 () const |
| | Return the level-1 sub-category.
|
| |
| Log::LogCategory | LVL2 () const |
| | Return the level-2 sub-category.
|
| |
| Log::LogCategory | LVL3 () const |
| | Return the level-3 sub-category.
|
| |
| void | logText (const char *file, int lineNumber, Log::LogLevel level, const QString &text) const |
| | Write a text message to the system logger using the base category.
|
| |
| void | logText (const char *file, int lineNumber, Log::LogLevel level, const Log::LogCategory &category, const QString &text) const |
| | Write a text message to the system logger using an explicit category.
|
| |
| void | logHex (const char *file, int lineNumber, Log::LogLevel level, const QByteArray &data, const QString &tag=QString()) const |
| | Write a hex dump to the system logger.
|
| |
| void | logHex (const char *file, int lineNumber, Log::LogLevel level, const Log::LogCategory &category, const QByteArray &data, const QString &tag=QString()) const |
| | Write a hex dump to the system logger using an explicit category.
|
| |
| void | addLogConsumer (LogConsumer *consumer) |
| | Register an external log consumer to receive entries from this class.
|
| |
| void | removeLogConsumer (LogConsumer *consumer) |
| | Remove a previously added log consumer.
|
| |
Abstract TCP server supporting both plain-text and TLS/SSL connections.
Subclass TcpServer and implement createClient() to construct the appropriate TcpServerClientObject for each incoming connection. The server runs its listen loop in a dedicated QThread; call start() and stop() to control it.
Definition at line 25 of file tcpserver.h.
◆ TcpServer() [1/3]
| TcpServer::TcpServer |
( |
const QHostAddress & |
serverAddress, |
|
|
int |
serverPort |
|
) |
| |
Construct a plain-text TCP server.
- Parameters
-
| serverAddress | Address to listen on |
| serverPort | Port to listen on |
◆ TcpServer() [2/3]
| TcpServer::TcpServer |
( |
const QHostAddress & |
serverAddress, |
|
|
int |
serverPort, |
|
|
const QSslKey & |
privateKey, |
|
|
const QSslCertificate & |
localCertificate, |
|
|
const QSslCertificate & |
caCert, |
|
|
bool |
verifyPeer = false |
|
) |
| |
Construct an SSL/TLS TCP server with a single CA certificate.
- Parameters
-
| serverAddress | Address to listen on |
| serverPort | Port to listen on |
| privateKey | Server private key |
| localCertificate | Server certificate |
| caCert | CA certificate for client verification |
| verifyPeer | Whether to require client certificate verification |
◆ TcpServer() [3/3]
| TcpServer::TcpServer |
( |
const QHostAddress & |
serverAddress, |
|
|
int |
serverPort, |
|
|
const QSslKey & |
privateKey, |
|
|
const QSslCertificate & |
localCertificate, |
|
|
const QList< QSslCertificate > & |
caCerts, |
|
|
bool |
verifyPeer = false |
|
) |
| |
Construct an SSL/TLS TCP server with a list of CA certificates.
- Parameters
-
| serverAddress | Address to listen on |
| serverPort | Port to listen on |
| privateKey | Server private key |
| localCertificate | Server certificate |
| caCerts | List of CA certificates |
| verifyPeer | Whether to require client certificate verification |
◆ caCerts()
| QList< QSslCertificate > TcpServer::caCerts |
( |
| ) |
const |
|
inline |
Return the list of CA certificates (SSL mode only).
- Returns
- List of CA certificates
Definition at line 79 of file tcpserver.h.
◆ createClient()
Factory method called for each incoming connection.
- Parameters
-
| server | Pointer to this server |
| fd | Native socket file descriptor for the new connection |
- Returns
- Newly allocated TcpServerClientObject to manage the connection
◆ incomingConnection()
| virtual void TcpServer::incomingConnection |
( |
qintptr |
handle | ) |
|
|
overrideprotectedvirtual |
Handle a new incoming connection by delegating to createClient().
- Parameters
-
| handle | Native socket descriptor for the incoming connection |
◆ localCertificate()
| QSslCertificate TcpServer::localCertificate |
( |
| ) |
const |
|
inline |
Return the server's local certificate (SSL mode only).
- Returns
- Server certificate
Definition at line 76 of file tcpserver.h.
◆ privateKey()
| QSslKey TcpServer::privateKey |
( |
| ) |
const |
|
inline |
Return the server's private key (SSL mode only).
- Returns
- Server private key
Definition at line 73 of file tcpserver.h.
◆ start()
| bool TcpServer::start |
( |
| ) |
|
Start the server and begin accepting connections.
- Returns
- true if the server started successfully
◆ startTime()
| QDateTime TcpServer::startTime |
( |
| ) |
const |
|
inline |
Return the time the server was started.
- Returns
- QDateTime of the last successful start()
Definition at line 88 of file tcpserver.h.
◆ verifyPeer()
| bool TcpServer::verifyPeer |
( |
| ) |
const |
|
inline |
Return whether peer certificate verification is enabled.
- Returns
- true if peer verification is enabled
Definition at line 82 of file tcpserver.h.
The documentation for this class was generated from the following file: