1// Copyright (C) 2017-2015 Ford Motor Company
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:declarations-only
4
5#ifndef QCONNECTIONTCPIPBACKEND_P_H
6#define QCONNECTIONTCPIPBACKEND_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qconnectionfactories_p.h"
20
21#include <QtNetwork/qtcpserver.h>
22#include <QtNetwork/qtcpsocket.h>
23
24QT_BEGIN_NAMESPACE
25
26class TcpClientIo final : public QtROClientIoDevice
27{
28 Q_OBJECT
29
30public:
31 explicit TcpClientIo(QObject *parent = nullptr);
32 ~TcpClientIo() override;
33
34 QIODevice *connection() const override;
35 void connectToServer() override;
36 bool isOpen() const override;
37
38public Q_SLOTS:
39 void onError(QAbstractSocket::SocketError error);
40 void onStateChanged(QAbstractSocket::SocketState state);
41
42protected:
43 void doClose() override;
44 void doDisconnectFromServer() override;
45
46private:
47 QTcpSocket *m_socket;
48};
49
50class TcpServerIo final : public QtROServerIoDevice
51{
52 Q_OBJECT
53public:
54 explicit TcpServerIo(QTcpSocket *conn, QObject *parent = nullptr);
55
56 QIODevice *connection() const override;
57protected:
58 void doClose() override;
59
60private:
61 QTcpSocket *m_connection;
62};
63
64class TcpServerImpl final : public QConnectionAbstractServer
65{
66 Q_OBJECT
67 Q_DISABLE_COPY(TcpServerImpl)
68
69public:
70 explicit TcpServerImpl(QObject *parent);
71 ~TcpServerImpl() override;
72
73 bool hasPendingConnections() const override;
74 QtROServerIoDevice *configureNewConnection() override;
75 QUrl address() const override;
76 bool listen(const QUrl &address) override;
77 QAbstractSocket::SocketError serverError() const override;
78 void close() override;
79
80private:
81 QTcpServer m_server;
82 QUrl m_originalUrl; // necessary because of a QHostAddress bug
83};
84
85QT_END_NAMESPACE
86#endif // QCONNECTIONTCPIPBACKEND_P_H
87

source code of qtremoteobjects/src/remoteobjects/qconnection_tcpip_backend_p.h