1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QLOCALSERVER_H
6#define QLOCALSERVER_H
7
8#include <QtNetwork/qtnetworkglobal.h>
9#include <QtNetwork/qabstractsocket.h>
10
11#include <QtCore/qproperty.h>
12
13QT_REQUIRE_CONFIG(localserver);
14
15QT_BEGIN_NAMESPACE
16
17class QLocalSocket;
18class QLocalServerPrivate;
19
20class Q_NETWORK_EXPORT QLocalServer : public QObject
21{
22 Q_OBJECT
23 Q_DECLARE_PRIVATE(QLocalServer)
24 Q_PROPERTY(SocketOptions socketOptions READ socketOptions WRITE setSocketOptions
25 BINDABLE bindableSocketOptions)
26
27Q_SIGNALS:
28 void newConnection();
29
30public:
31 enum SocketOption {
32 NoOptions = 0x0,
33 UserAccessOption = 0x01,
34 GroupAccessOption = 0x2,
35 OtherAccessOption = 0x4,
36 WorldAccessOption = 0x7,
37 AbstractNamespaceOption = 0x8
38 };
39 Q_ENUM(SocketOption)
40 Q_DECLARE_FLAGS(SocketOptions, SocketOption)
41 Q_FLAG(SocketOptions)
42
43 explicit QLocalServer(QObject *parent = nullptr);
44 ~QLocalServer();
45
46 void close();
47 QString errorString() const;
48 virtual bool hasPendingConnections() const;
49 bool isListening() const;
50 bool listen(const QString &name);
51 bool listen(qintptr socketDescriptor);
52 int maxPendingConnections() const;
53 virtual QLocalSocket *nextPendingConnection();
54 QString serverName() const;
55 QString fullServerName() const;
56 static bool removeServer(const QString &name);
57 QAbstractSocket::SocketError serverError() const;
58 void setMaxPendingConnections(int numConnections);
59 bool waitForNewConnection(int msec = 0, bool *timedOut = nullptr);
60
61 void setListenBacklogSize(int size);
62 int listenBacklogSize() const;
63
64 void setSocketOptions(SocketOptions options);
65 SocketOptions socketOptions() const;
66 QBindable<SocketOptions> bindableSocketOptions();
67
68 qintptr socketDescriptor() const;
69
70protected:
71 virtual void incomingConnection(quintptr socketDescriptor);
72 void addPendingConnection(QLocalSocket *socket);
73
74private:
75 Q_DISABLE_COPY(QLocalServer)
76 Q_PRIVATE_SLOT(d_func(), void _q_onNewConnection())
77};
78
79Q_DECLARE_OPERATORS_FOR_FLAGS(QLocalServer::SocketOptions)
80
81QT_END_NAMESPACE
82
83#endif // QLOCALSERVER_H
84
85

source code of qtbase/src/network/socket/qlocalserver.h