11#include <promeki/config.h>
12#if PROMEKI_ENABLE_NETWORK
17PROMEKI_NAMESPACE_BEGIN
40class TcpServer :
public ObjectBase {
41 PROMEKI_OBJECT(TcpServer, ObjectBase)
47 TcpServer(ObjectBase *parent =
nullptr);
50 ~TcpServer()
override;
58 Error listen(
const SocketAddress &address,
int backlog = 50);
64 bool isListening()
const {
return _listening; }
67 SocketAddress serverAddress()
const {
return _address; }
77 TcpSocket *nextPendingConnection();
92 int nextPendingDescriptor();
98 bool hasPendingConnections()
const;
105 Error waitForNewConnection(
unsigned int timeoutMs = 0);
111 void setMaxPendingConnections(
int count) { _maxPending = count; }
123 int socketDescriptor()
const {
return _fd; }
136 Error setNonBlocking(
bool enable);
139 PROMEKI_SIGNAL(newConnection);
143 bool _listening =
false;
144 SocketAddress _address;
145 int _maxPending = 50;