Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
tcpsocket.h
Go to the documentation of this file.
1// Copyright (C) 2024 Jarek Kobus
2// Copyright (C) 2024 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef TASKING_TCPSOCKET_H
6#define TASKING_TCPSOCKET_H
7
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21#include "tasktree.h"
22
23#include <QtNetwork/QTcpSocket>
24
25#include <memory>
26
28
29namespace Tasking {
30
31// This class introduces the dependency to Qt::Network, otherwise Tasking namespace
32// is independent on Qt::Network.
33// Possibly, it could be placed inside Qt::Network library, as a wrapper around QTcpSocket.
34
35class TASKING_EXPORT TcpSocket final : public QObject
36{
38
39public:
40 ~TcpSocket();
41 void setAddress(const QHostAddress &address) { m_address = address; }
42 void setPort(quint16 port) { m_port = port; }
43 void setWriteData(const QByteArray &data) { m_writeData = data; }
44 QTcpSocket *socket() const { return m_socket.get(); }
45 void start();
46
48 void started();
49 void done(DoneResult result);
50
51private:
52 QHostAddress m_address;
53 quint16 m_port = 0;
54 QByteArray m_writeData;
55 std::unique_ptr<QTcpSocket> m_socket;
56 QAbstractSocket::SocketError m_error = QAbstractSocket::UnknownSocketError;
57};
58
60
61} // namespace Tasking
62
63QT_END_NAMESPACE
64
65#endif // TASKING_TCPSOCKET_H
void done(DoneResult result)
void setAddress(const QHostAddress &address)
Definition tcpsocket.h:41
void setWriteData(const QByteArray &data)
Definition tcpsocket.h:43
void setPort(quint16 port)
Definition tcpsocket.h:42
QTcpSocket * socket() const
Definition tcpsocket.h:44
\inmodule TaskingSolution
#define TASKING_EXPORT