8#if defined(Q_OS_WIN) && !defined(QT_LOCALSOCKET_TCP)
9#include <QtCore/qt_windows.h>
150 d->socketOptions = options;
162 return d->socketOptions;
168 return &
d->socketOptions;
196#if defined(QT_LOCALSOCKET_TCP)
197 return d->tcpServer.socketDescriptor();
198#elif defined(Q_OS_WIN)
199 const auto handle =
d->connectionEventNotifier->handle();
202 return d->socketNotifier->socket();
218 d->pendingConnections.clear();
220 d->serverName.clear();
221 d->fullServerName.clear();
222 d->errorString.clear();
236 return d->errorString;
248 return !(
d->pendingConnections.isEmpty());
289 d->pendingConnections.enqueue(
socket);
302 return !(
d->serverName.isEmpty());
329 qWarning(
"QLocalServer::listen() called when already listening");
333 if (
name.isEmpty()) {
335 QString function =
"QLocalServer::listen"_L1;
336 d->errorString =
tr(
"%1: Name error").arg(function);
340 if (!
d->listen(
name)) {
341 d->serverName.clear();
342 d->fullServerName.clear();
346 d->serverName =
name;
372 qWarning(
"QLocalServer::listen() called when already listening");
376 d->serverName.clear();
377 d->fullServerName.clear();
395 return d->maxPendingConnections;
422 if (
d->pendingConnections.isEmpty())
425#ifndef QT_LOCALSOCKET_TCP
426 if (
d->pendingConnections.size() <=
d->maxPendingConnections)
428 d->socketNotifier->setEnabled(
true);
430 d->connectionEventNotifier->setEnabled(
true);
463 return d->serverName;
476 return d->fullServerName;
506 d->maxPendingConnections = numConnections;
535 d->waitForNewConnection(msec, timedOut);
537 return !
d->pendingConnections.isEmpty();
554 d->listenBacklog =
size;
567 return d->listenBacklog;
572#include "moc_qlocalserver.cpp"
SocketError
This enum describes the socket errors that can occur.
virtual bool setSocketDescriptor(qintptr socketDescriptor, SocketState state=ConnectedState, OpenMode openMode=ReadWrite)
Initializes QAbstractSocket with the native socket descriptor socketDescriptor.
static bool removeServer(const QString &name)
The QLocalServer class provides a local socket based server.
QString fullServerName() const
Returns the full path that the server is listening on.
bool waitForNewConnection(int msec=0, bool *timedOut=nullptr)
Waits for at most msec milliseconds or until an incoming connection is available.
QString errorString() const
Returns the human-readable message appropriate to the current error reported by serverError().
virtual void incomingConnection(quintptr socketDescriptor)
This virtual function is called by QLocalServer when a new connection is available.
void newConnection()
This signal is emitted every time a new connection is available.
QLocalServer(QObject *parent=nullptr)
Create a new local socket server with the given parent.
SocketOptions socketOptions
the socket options that control how the socket operates.
QAbstractSocket::SocketError serverError() const
Returns the type of error that occurred last or NoError.
void setSocketOptions(SocketOptions options)
void setListenBacklogSize(int size)
Sets the backlog queue size of to be accepted connections to size.
QBindable< SocketOptions > bindableSocketOptions()
int maxPendingConnections() const
Returns the maximum number of pending accepted connections.
virtual bool hasPendingConnections() const
Returns true if the server has a pending connection; otherwise returns false.
QString serverName() const
Returns the server name if the server is listening for connections; otherwise returns QString()
int listenBacklogSize() const
Returns the backlog queue size of to be accepted connections.
static bool removeServer(const QString &name)
void addPendingConnection(QLocalSocket *socket)
This function is called by QLocalServer::incomingConnection() to add the socket to the list of pendin...
~QLocalServer()
Destroys the QLocalServer object.
bool listen(const QString &name)
Tells the server to listen for incoming connections on name.
virtual QLocalSocket * nextPendingConnection()
Returns the next pending connection as a connected QLocalSocket object.
void close()
Stop listening for incoming connections.
qintptr socketDescriptor() const
bool isListening() const
Returns true if the server is listening for incoming connections otherwise false.
void setMaxPendingConnections(int numConnections)
Sets the maximum number of pending accepted connections to numConnections.
The QLocalSocket class provides a local socket.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
GLuint64 GLenum void * handle
GLenum GLuint GLintptr GLsizeiptr size
[1]