Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qlocalsocket_p.h
Go to the documentation of this file.
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
4#ifndef QLOCALSOCKET_P_H
5#define QLOCALSOCKET_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the QLocalSocket class. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19
20#include "qlocalsocket.h"
21#include "private/qiodevice_p.h"
22
23#include <qtimer.h>
24
25QT_REQUIRE_CONFIG(localserver);
26
27#if defined(QT_LOCALSOCKET_TCP)
28# include "qtcpsocket.h"
29#elif defined(Q_OS_WIN)
30# include "private/qwindowspipereader_p.h"
31# include "private/qwindowspipewriter_p.h"
32# include <qwineventnotifier.h>
33#else
34# include "private/qabstractsocketengine_p.h"
35# include <qtcpsocket.h>
36# include <qsocketnotifier.h>
37# include <errno.h>
38#endif
39
40struct sockaddr_un;
41
43
44#if !defined(Q_OS_WIN) || defined(QT_LOCALSOCKET_TCP)
45
47{
48
49public:
51 {
52 };
53
58
59 inline void setErrorString(const QString &string)
60 {
62 }
63
68
69 inline qint64 readData(char *data, qint64 maxSize) override
70 {
71 return QTcpSocket::readData(data, maxSize);
72 }
73
74 inline qint64 writeData(const char *data, qint64 maxSize) override
75 {
76 return QTcpSocket::writeData(data, maxSize);
77 }
78};
79#endif //#if !defined(Q_OS_WIN) || defined(QT_LOCALSOCKET_TCP)
80
82{
83public:
84 Q_DECLARE_PUBLIC(QLocalSocket)
85
87 void init();
88
89#if defined(QT_LOCALSOCKET_TCP)
90 QLocalUnixSocket* tcpSocket;
91 bool ownsTcpSocket;
92 void setSocket(QLocalUnixSocket*);
97#elif defined(Q_OS_WIN)
99 qint64 pipeWriterBytesToWrite() const;
100 void _q_canRead();
101 void _q_bytesWritten(qint64 bytes);
102 void _q_pipeClosed();
103 void _q_winError(ulong windowsError, const QString &function);
104 void _q_writeFailed();
105 HANDLE handle;
106 QWindowsPipeWriter *pipeWriter;
107 QWindowsPipeReader *pipeReader;
109#else
115 void _q_connectToSocket();
118 void describeSocket(qintptr socketDescriptor);
119 static bool parseSockaddr(const sockaddr_un &addr, uint len,
120 QString &fullServerName, QString &serverName, bool &abstractNamespace);
125 QIODevice::OpenMode connectingOpenMode;
126#endif
130#if defined(Q_OS_WIN) && !defined(QT_LOCALSOCKET_TCP)
131 bool emittedReadyRead;
132 bool emittedBytesWritten;
133#endif
134
135 Q_OBJECT_BINDABLE_PROPERTY(QLocalSocketPrivate, QLocalSocket::SocketOptions, socketOptions)
136};
137
139
140#endif // QLOCALSOCKET_P_H
141
SocketState
This enum describes the different states in which a socket can be.
void setSocketError(SocketError socketError)
Sets the type of error that last occurred to socketError.
SocketState state() const
Returns the state of the socket.
SocketError
This enum describes the socket errors that can occur.
void setSocketState(SocketState state)
Sets the state of the socket to state.
SocketError error() const
Returns the type of error that last occurred.
void setErrorString(const QString &errorString)
Sets the human readable description of the last device error that occurred to str.
virtual qint64 writeData(const char *data, qint64 len)=0
Writes up to maxSize bytes from data to the device.
virtual qint64 readData(char *data, qint64 maxlen)=0
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
static bool parseSockaddr(const sockaddr_un &addr, uint len, QString &fullServerName, QString &serverName, bool &abstractNamespace)
void _q_stateChanged(QAbstractSocket::SocketState newState)
void describeSocket(qintptr socketDescriptor)
QLocalUnixSocket unixSocket
QLocalSocket::LocalSocketState state
void _q_errorOccurred(QAbstractSocket::SocketError newError)
void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function)
QIODevice::OpenMode connectingOpenMode
QSocketNotifier * delayConnect
QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const
The QLocalSocket class provides a local socket.
LocalSocketState
This enum describes the different states in which a socket can be.
LocalSocketError
The LocalServerError enumeration represents the errors that can occur.
void setErrorString(const QString &string)
void setSocketState(QAbstractSocket::SocketState state)
qint64 writeData(const char *data, qint64 maxSize) override
\reimp
void setSocketError(QAbstractSocket::SocketError error)
qint64 readData(char *data, qint64 maxSize) override
\reimp
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QTcpSocket class provides a TCP socket.
Definition qtcpsocket.h:18
\inmodule QtCore
Definition qtimer.h:20
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 * error
GLuint64 GLenum void * handle
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum const void * addr
GLenum GLsizei len
#define Q_OBJECT_BINDABLE_PROPERTY(...)
Definition qproperty.h:1239
#define QT_REQUIRE_CONFIG(feature)
unsigned long ulong
Definition qtypes.h:35
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
ptrdiff_t qintptr
Definition qtypes.h:166