32 ownsTcpSocket =
false;
39 q->connect(tcpSocket,
SIGNAL(readyRead()),
q,
SIGNAL(readyRead()));
42 q->connect(tcpSocket,
SIGNAL(disconnected()),
q,
SIGNAL(disconnected()));
47 q->connect(tcpSocket,
SIGNAL(readChannelFinished()),
q,
SIGNAL(readChannelFinished()));
48 tcpSocket->setParent(
q);
81#if defined QLOCALSOCKET_DEBUG
86 if (currentState !=
state)
177 q->emit stateChanged(
state);
189 d->errorString.clear();
193 if (
d->serverName.isEmpty()) {
198 const auto prefix =
"QLocalServer/"_L1;
199 if (
d->serverName.startsWith(prefix))
200 d->fullServerName =
d->serverName;
202 d->fullServerName = prefix +
d->serverName;
220 switch (socketState) {
235 d->state = socketState;
258 return d->tcpSocket->socketDescriptor();
264 return d->tcpSocket->read(
data,
c);
274 return d_func()->tcpSocket->readLine(
data, maxSize + 1);
279 return d_func()->tcpSocket->skip(maxSize);
285 return d->tcpSocket->writeData(
data,
c);
291 d->tcpSocket->abort();
304 return d->tcpSocket->bytesToWrite();
318 d->tcpSocket->close();
319 d->serverName.clear();
320 d->fullServerName.clear();
326 return d->tcpSocket->waitForBytesWritten(msecs);
332 return d->tcpSocket->flush();
338 d->tcpSocket->disconnectFromHost();
344 switch (
d->tcpSocket->error()) {
366#if defined QLOCALSOCKET_DEBUG
367 qWarning() <<
"QLocalSocket error not handled:" <<
d->tcpSocket->error();
377 return d->tcpSocket->isValid();
383 return d->tcpSocket->readBufferSize();
389 d->tcpSocket->setReadBufferSize(
size);
398 return d->tcpSocket->waitForConnected(msec);
405 qWarning(
"QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState");
408 return (
d->tcpSocket->waitForDisconnected(msecs));
416 return (
d->tcpSocket->waitForReadyRead(msecs));
SocketState
This enum describes the different states in which a socket can be.
virtual qintptr socketDescriptor() const
Returns the native socket descriptor of the QAbstractSocket object if this is available; otherwise re...
SocketError
This enum describes the socket errors that can occur.
@ UnsupportedSocketOperationError
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
void setErrorString(const QString &errorString)
Sets the human readable description of the last device error that occurred to str.
QIODeviceBase::OpenMode openMode() const
Returns the mode in which the device has been opened; i.e.
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
virtual bool canReadLine() const
Returns true if a complete line of data can be read from the device; otherwise returns false.
The QLocalServer class provides a local socket based server.
void _q_stateChanged(QAbstractSocket::SocketState newState)
QLocalSocket::LocalSocketState state
void _q_errorOccurred(QAbstractSocket::SocketError newError)
void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function)
QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const
The QLocalSocket class provides a local socket.
bool setSocketDescriptor(qintptr socketDescriptor, LocalSocketState socketState=ConnectedState, OpenMode openMode=ReadWrite)
Initializes QLocalSocket with the native socket descriptor socketDescriptor.
LocalSocketState state() const
Returns the state of the socket.
virtual qint64 readData(char *, qint64) override
\reimp
void abort()
Aborts the current connection and resets the socket.
virtual qint64 bytesToWrite() const override
\reimp
virtual bool canReadLine() const override
\reimp
bool waitForBytesWritten(int msecs=30000) override
\reimp
LocalSocketState
This enum describes the different states in which a socket can be.
bool isValid() const
Returns true if the socket is valid and ready for use; otherwise returns false.
bool flush()
This function writes as much as possible from the internal write buffer to the socket,...
LocalSocketError error() const
Returns the type of error that last occurred.
qint64 readBufferSize() const
Returns the size of the internal read buffer.
bool waitForDisconnected(int msecs=30000)
Waits until the socket has disconnected, up to msecs milliseconds.
void disconnectFromServer()
Attempts to close the socket.
qint64 readLineData(char *data, qint64 maxSize) override
\reimp
bool waitForConnected(int msecs=30000)
Waits until the socket is connected, up to msecs milliseconds.
bool waitForReadyRead(int msecs=30000) override
This function blocks until data is available for reading and the \l{QIODevice::}{readyRead()} signal ...
void connectToServer(OpenMode openMode=ReadWrite)
void setReadBufferSize(qint64 size)
Sets the size of QLocalSocket's internal read buffer to be size bytes.
qintptr socketDescriptor() const
Returns the native socket descriptor of the QLocalSocket object if this is available; otherwise retur...
virtual void close() override
Closes the I/O device for the socket and calls disconnectFromServer() to close the socket's connectio...
qint64 skipData(qint64 maxSize) override
\reimp
virtual qint64 bytesAvailable() const override
\reimp
void stateChanged(QLocalSocket::LocalSocketState socketState)
This signal is emitted whenever QLocalSocket's state changes.
virtual qint64 writeData(const char *, qint64) override
\reimp
LocalSocketError
The LocalServerError enumeration represents the errors that can occur.
@ UnsupportedSocketOperationError
void errorOccurred(QLocalSocket::LocalSocketError socketError)
const QObjectList & children() const
Returns a list of child objects.
QObject * parent() const
Returns a pointer to the parent object.
QVariant value(QAnyStringView key, const QVariant &defaultValue) const
Returns the value for setting key.
\macro QT_RESTRICTED_CAST_FROM_ASCII
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
The QTcpSocket class provides a TCP socket.
uint toUInt(bool *ok=nullptr) const
Returns the variant as an unsigned int if the variant has userType() \l QMetaType::UInt,...
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
DBusConnection const char DBusError * error
GLenum GLsizei GLuint GLint * bytesWritten
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLdouble GLdouble GLdouble GLdouble q
QSettings settings("MySoft", "Star Runner")
[0]