12#include <sys/socket.h>
22# include <selectLib.h>
30QLocalServer::SocketOptions optionsForPlatform(QLocalServer::SocketOptions srcOptions)
53 if (
name.startsWith(u
'/')) {
70 auto options = optionsForPlatform(socketOptions.value());
84 std::optional<QTemporaryDir> tempDir;
88 tempDir.emplace(serverNameFileInfo.absolutePath() + u
'/');
89 if (!tempDir->isValid()) {
105 struct ::sockaddr_un
addr;
107 addr.sun_family = PF_UNIX;
108 ::memset(
addr.sun_path, 0,
sizeof(
addr.sun_path));
113 if (
sizeof(
addr.sun_path) <
static_cast<size_t>(encodedFullServerName.
size() + extraCharacters)) {
114 setError(
"QLocalServer::listen"_L1);
119 QT_SOCKLEN_T addrSize =
sizeof(::sockaddr_un);
123 ::memcpy(
addr.sun_path + 1, encodedFullServerName.
constData(),
124 encodedFullServerName.
size() + 1);
125 addrSize = offsetof(::sockaddr_un, sun_path) + encodedFullServerName.
size() + 1;
127 if (
sizeof(
addr.sun_path) <
static_cast<size_t>(encodedTempPath.
size() + 1)) {
128 setError(
"QLocalServer::listen"_L1);
133 encodedTempPath.
size() + 1);
136 encodedFullServerName.
size() + 1);
141 setError(
"QLocalServer::listen"_L1);
143 if (errno == EADDRINUSE)
154 setError(
"QLocalServer::listen"_L1);
172 setError(
"QLocalServer::listen"_L1);
178 setError(
"QLocalServer::listen"_L1);
203 bool abstractAddress =
false;
204 struct ::sockaddr_un
addr;
205 QT_SOCKLEN_T
len =
sizeof(
addr);
207 if (::getsockname(socketDescriptor, (sockaddr *)&
addr, &
len) == 0) {
209 if (
addr.sun_path[0] == 0 &&
addr.sun_path[1] == 0)
214 QLocalServer::SocketOptions options = socketOptions.value();
267 QT_SOCKLEN_T
length =
sizeof(sockaddr_un);
269 if (-1 == connectedSocket) {
270 setError(
"QLocalSocket::activated"_L1);
275 q->incomingConnection(connectedSocket);
291 if ((pfd.revents & POLLNVAL) == 0) {
299 setError(
"QLocalServer::waitForNewConnection"_L1);
329 errorString = QLocalServer::tr(
"%1: Unknown error %2")
332#if defined QLOCALSERVER_DEBUG
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
static QString tempPath()
Returns the absolute canonical path of the system's temporary directory.
static QString cleanPath(const QString &path)
Returns path with directory separators normalized (that is, platform-native separators converted to "...
\inmodule QtCore \reentrant
bool remove()
Removes the file specified by fileName().
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const noexcept
void waitForNewConnection(int msec, bool *timedOut)
static bool removeServer(const QString &name)
void setError(const QString &function)
QQueue< QLocalSocket * > pendingConnections
void _q_onNewConnection()
QAbstractSocket::SocketError error
int maxPendingConnections
bool listen(const QString &name)
QSocketNotifier * socketNotifier
The QLocalServer class provides a local socket based server.
@ AbstractNamespaceOption
static bool parseSockaddr(const sockaddr_un &addr, uint len, QString &fullServerName, QString &serverName, bool &abstractNamespace)
void deleteLater()
\threadsafe
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
void clear()
Clears the contents of the string and makes it null.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Combined button and popup list for selecting options.
static struct pollfd qt_make_pollfd(int fd, short events)
static int qt_poll_msecs(struct pollfd *fds, nfds_t nfds, int timeout)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
static int qt_safe_listen(int s, int backlog)
static int qt_safe_socket(int domain, int type, int protocol, int flags=0)
static int qt_safe_accept(int s, struct sockaddr *addr, QT_SOCKLEN_T *addrlen, int flags=0)
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble q
@ PlatformSupportsAbstractNamespace
bool testFlag(MaskType mask, FlagType flag)