libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
localserver.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_NETWORK
13#include <cstdint>
14#include <promeki/objectbase.h>
15#include <promeki/error.h>
16#include <promeki/string.h>
17
18PROMEKI_NAMESPACE_BEGIN
19
20class LocalSocket;
21
50class LocalServer : public ObjectBase {
51 PROMEKI_OBJECT(LocalServer, ObjectBase)
52 public:
54 static constexpr int DefaultBacklog = 50;
55
57 static constexpr uint32_t DefaultPermissions = 0600;
58
60 static bool isSupported();
61
66 LocalServer(ObjectBase *parent = nullptr);
67
69 ~LocalServer() override;
70
85 Error listen(const String &path, uint32_t mode = DefaultPermissions, const String &groupName = String(),
86 int backlog = DefaultBacklog);
87
89 void close();
90
92 bool isListening() const { return _listening; }
93
95 const String &serverPath() const { return _path; }
96
106 LocalSocket *nextPendingConnection();
107
109 bool hasPendingConnections() const;
110
116 Error waitForNewConnection(unsigned int timeoutMs = 0);
117
119 int socketDescriptor() const { return _fd; }
120
122 PROMEKI_SIGNAL(newConnection);
123
124 private:
125 int _fd = -1;
126 bool _listening = false;
127 bool _unlinkOnClose = false;
128 String _path;
129};
130
131PROMEKI_NAMESPACE_END
132
133#endif // PROMEKI_ENABLE_NETWORK